Esempio n. 1
0
        /// <summary>
        /// 上传头像
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="postedFile">上传的二进制头像文件</param>
        public static void UploadOriginalAvatar(this IUserService userService, long userId, Stream postedFile)
        {
            if (postedFile == null)
            {
                return;
            }
            Image image = Image.FromStream(postedFile);

            IUserProfileSettingsManager userProfileSettingsManager = DIContainer.Resolve <IUserProfileSettingsManager>();
            UserProfileSettings         userProfileSettings        = userProfileSettingsManager.GetUserProfileSettings();

            //检查是否需要缩放原图
            if (image.Height > userProfileSettings.OriginalAvatarHeight || image.Width > userProfileSettings.OriginalAvatarWidth)
            {
                postedFile = ImageProcessor.Resize(postedFile, userProfileSettings.OriginalAvatarWidth, userProfileSettings.OriginalAvatarHeight, ResizeMethod.KeepAspectRatio);
            }

            string relativePath = GetAvatarRelativePath(userId);

            IStoreProvider storeProvider = DIContainer.Resolve <IStoreProvider>();

            storeProvider.AddOrUpdateFile(relativePath, GetAvatarFileName(userId, AvatarSizeType.Original), postedFile);
            postedFile.Dispose();
            //1、如果原图超过一定尺寸(可以配置宽高像素值)则原图保留前先缩小(原图如果太大,裁剪时不方便操作)再保存
        }
Esempio n. 2
0
        public string CreateNewJob([FromBody] JobScheduleData data)
        {
            // Reconstruct
            var job      = data.Job.CreateJob();
            var schedule = data.Schedule.CreateSchedule(job);

            // See if we can use it
            if (!schedule.IsActive)
            {
                throw new ArgumentException(Properties.Resources.ScheduleInPast);
            }

            // Connect
            job.Schedules.Add(schedule);

            // Process
            ServerRuntime.VCRServer.UpdateJob(job, schedule.UniqueID.Value);

            // Update recently used channels
            UserProfileSettings.AddRecentChannel(data.Job.Source);
            UserProfileSettings.AddRecentChannel(data.Schedule.Source);

            // Report
            return(ServerRuntime.GetUniqueWebId(job, schedule));
        }
        public UserProfileOptionsControl(Lifetime lifetime,
                                         OptionsSettingsSmartContext ctx,
                                         KaVEISettingsStore settingsStore,
                                         IActionExecutor actionExecutor,
                                         DataContexts dataContexts,
                                         IMessageBoxCreator messageBoxCreator,
                                         IUserProfileSettingsUtils userProfileUtils)
        {
            _messageBoxCreator = messageBoxCreator;
            _userProfileUtils  = userProfileUtils;
            _lifetime          = lifetime;
            _ctx            = ctx;
            _settingsStore  = settingsStore;
            _actionExecutor = actionExecutor;
            _dataContexts   = dataContexts;

            InitializeComponent();

            userProfileUtils.EnsureProfileId();

            _userProfileSettings = userProfileUtils.GetSettings();

            _userProfileContext = new UserProfileContext(_userProfileSettings, userProfileUtils);
            _userProfileContext.PropertyChanged += UserProfileContextOnPropertyChanged;

            DataContext = _userProfileContext;

            if (_ctx != null)
            {
                BindToUserProfileChanges();
            }
        }
        public void Setup()
        {
            _userSettings = new UserProfileSettings
            {
                HasBeenAskedToFillProfile = false,
                ProfileId            = "",
                Education            = Educations.Unknown,
                Position             = Positions.Unknown,
                ProjectsCourses      = false,
                ProjectsPersonal     = false,
                ProjectsSharedSmall  = false,
                ProjectsSharedMedium = false,
                ProjectsSharedLarge  = false,
                TeamsSolo            = false,
                TeamsSmall           = false,
                TeamsMedium          = false,
                TeamsLarge           = false,
                CodeReviews          = YesNoUnknown.Unknown,
                ProgrammingGeneral   = Likert7Point.Unknown,
                ProgrammingCSharp    = Likert7Point.Unknown
            };

            _settingsStore = Mock.Of <ISettingsStore>();
            Mock.Get(_settingsStore).Setup(s => s.GetSettings <UserProfileSettings>()).Returns(_userSettings);

            _sut = new UserProfileEventGenerator(
                TestRSEnv,
                TestMessageBus,
                TestDateUtils,
                _settingsStore,
                TestThreading);
        }
Esempio n. 5
0
        public void UpdateGuideFavorites(string favorites)
        {
            // Just store body as data
            UserProfileSettings.GuideFavorites = ControllerContext.Request.Content.ReadAsStringAsync().Result ?? string.Empty;

            // And update
            UserProfileSettings.Update();
        }
        public void SetUp()
        {
            _settings = new UserProfileSettings();
            _util     = Mock.Of <IUserProfileSettingsUtils>();
            Mock.Get(_util).Setup(u => u.GetSettings()).Returns(_settings);

            _actionExecutor     = Mock.Of <IActionExecutor>();
            _uploadWizardPolicy = UploadWizardPolicy.OpenUploadWizardOnFinish;
        }
Esempio n. 7
0
        /// <summary>
        /// 更新完成度
        /// </summary>
        /// <param name="userId">用户Id</param>
        public void UpdateIntegrity(long userId)
        {
            ISettingsManager <UserProfileSettings> userProfileSettingsManager = DIContainer.Resolve <ISettingsManager <UserProfileSettings> >();
            UserProfileSettings userProfileSettings = userProfileSettingsManager.Get();

            int[] integrityItems = userProfileSettings.IntegrityProportions;
            int   integrity      = integrityItems[(int)ProfileIntegrityItems.Birthday];

            Database dao = CreateDAO();

            dao.OpenSharedConnection();
            var sql = Sql.Builder;

            sql.Select("Count(*)")
            .From("spb_EducationExperiences")
            .Where("UserId = @0", userId);

            int countEducation = dao.ExecuteScalar <int>(sql);

            if (countEducation > 0)
            {
                integrity += integrityItems[(int)ProfileIntegrityItems.EducationExperience];
            }

            sql = Sql.Builder;
            sql.Select("count(*)")
            .From("spb_WorkExperiences")
            .Where("UserId = @0", userId);
            int countWork = dao.ExecuteScalar <int>(sql);

            if (countWork > 0)
            {
                integrity += integrityItems[(int)ProfileIntegrityItems.WorkExperience];
            }

            sql = Sql.Builder;
            sql.Where("userId = @0", userId);
            UserProfile userProfile = dao.FirstOrDefault <UserProfile>(sql);

            if (userProfile != null)
            {
                IUser user = DIContainer.Resolve <UserService>().GetUser(userProfile.UserId);

                integrity += (user.HasAvatar ? integrityItems[(int)ProfileIntegrityItems.Avatar] : 0);
                integrity += (userProfile.HasHomeAreaCode ? integrityItems[(int)ProfileIntegrityItems.HomeArea] : 0);
                integrity += (userProfile.HasIM ? integrityItems[(int)ProfileIntegrityItems.IM] : 0);
                integrity += (userProfile.HasIntroduction ? integrityItems[(int)ProfileIntegrityItems.Introduction] : 0);
                integrity += (userProfile.HasMobile ? integrityItems[(int)ProfileIntegrityItems.Mobile] : 0);
                integrity += (userProfile.HasNowAreaCode ? integrityItems[(int)ProfileIntegrityItems.NowArea] : 0);

                userProfile.Integrity = integrity;
                Update(userProfile);
            }

            dao.CloseSharedConnection();
        }
Esempio n. 8
0
        public void SetUp()
        {
            _rndGuid = "xyz";

            _userProfileSettings     = new UserProfileSettings();
            _userProfileSettingsUtil = Mock.Of <IUserProfileSettingsUtils>();
            Mock.Get(_userProfileSettingsUtil).Setup(u => u.CreateNewProfileId()).Returns(_rndGuid);

            _dataContext = new UserProfileContext(_userProfileSettings, _userProfileSettingsUtil);
        }
        public ISmsNotification Create(NotificationMessage message, UserProfileSettings settings)
        {
            if (!registry.TryGetValue(message.Event, out var messageType))
            {
                throw new InvalidOperationException(string.Format(EventIsNotSupportedExceptionMessage, message.Event));
            }

            var notification = (ISmsNotification)DynamicExtensions.ToStatic(messageType, message.Parameters);

            return(notification);
        }
        public void SetUp()
        {
            var userProfileId = Guid.NewGuid().ToString();

            _userProfileSettings = new UserProfileSettings {
                ProfileId = userProfileId
            };
            var ss = new Mock <ISettingsStore>();

            ss.Setup(u => u.GetSettings <UserProfileSettings>()).Returns(_userProfileSettings);
            _sut = new RandomizedModelEnabler(ss.Object);
        }
        public void Setup()
        {
            _settings      = new UserProfileSettings();
            _settingsStore = Mock.Of <ISettingsStore>();
            Mock.Get(_settingsStore).Setup(ss => ss.GetSettings <UserProfileSettings>()).Returns(_settings);

            _rndGuid = Guid.NewGuid();
            _rnd     = Mock.Of <IRandomizationUtils>();
            Mock.Get(_rnd).Setup(r => r.GetRandomGuid()).Returns(_rndGuid);

            _sut = new UserProfileSettingsUtils(_settingsStore, _rnd);
        }
Esempio n. 12
0
        /// <summary>
        /// 根据用户自己选择的尺寸及位置进行头像裁剪
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="srcWidth">需裁剪的宽度</param>
        /// <param name="srcHeight">需裁剪的高度</param>
        /// <param name="srcX">需裁剪的左上角点坐标</param>
        /// <param name="srcY">需裁剪的左上角点坐标</param>
        public static void CropAvatar(this IUserService userService, long userId, float srcWidth, float srcHeight, float srcX, float srcY)
        {
            IStoreProvider storeProvider = DIContainer.Resolve <IStoreProvider>();
            IStoreFile     iStoreFile    = storeProvider.GetFile(GetAvatarRelativePath(userId), GetAvatarFileName(userId, AvatarSizeType.Original));

            if (iStoreFile == null)
            {
                return;
            }
            User user = GetFullUser(userService, userId);

            if (user == null)
            {
                return;
            }

            bool   isFirst            = !(user.Profile.IsUploadedAvatar);
            string avatarRelativePath = GetAvatarRelativePath(userId).Replace(Path.DirectorySeparatorChar, '/');

            avatarRelativePath = avatarRelativePath.Substring(AvatarDirectory.Length + 1);
            user.Avatar        = avatarRelativePath + "/" + userId;

            IUserRepository userRepository = userService.GetUserRepository();

            userRepository.UpdateAvatar(user, user.Avatar);

            UserProfileSettings userProfileSettings = DIContainer.Resolve <ISettingsManager <UserProfileSettings> >().Get();

            using (Stream fileStream = iStoreFile.OpenReadStream())
            {
                Stream bigImage = ImageProcessor.Crop(fileStream, new Rectangle((int)srcX, (int)srcY, (int)srcWidth, (int)srcHeight), userProfileSettings.AvatarWidth, userProfileSettings.AvatarHeight);

                Stream smallImage = ImageProcessor.Resize(bigImage, userProfileSettings.SmallAvatarWidth, userProfileSettings.SmallAvatarHeight, ResizeMethod.KeepAspectRatio);
                storeProvider.AddOrUpdateFile(GetAvatarRelativePath(userId), GetAvatarFileName(userId, AvatarSizeType.Big), bigImage);
                storeProvider.AddOrUpdateFile(GetAvatarRelativePath(userId), GetAvatarFileName(userId, AvatarSizeType.Small), smallImage);

                bigImage.Dispose();
                smallImage.Dispose();
                fileStream.Close();
            }

            //触发用户更新头像事件
            EventBus <User, CropAvatarEventArgs> .Instance().OnAfter(user, new CropAvatarEventArgs(isFirst));

            if (isFirst)
            {
                user.Profile.IsUploadedAvatar = true;
                new UserProfileService().Update(user.Profile);
            }
        }
Esempio n. 13
0
        public PushNotificationMessage Create(NotificationMessage message, UserProfileSettings settings)
        {
            if (!registry.TryGetValue(message.Event, out var messageType))
            {
                throw new InvalidOperationException($"{message.Event} event is not supported");
            }

            PushNotificationMessage notification = (PushNotificationMessage)DynamicExtensions.ToStatic(messageType, message.Parameters);
            var typeName = messageType.Name;

            notification.Body  = _resourceProvider.GetBody(typeName, settings.Language);
            notification.Title = _resourceProvider.GetTitle(typeName, settings.Language);
            return(notification);
        }
Esempio n. 14
0
        public IEmailNotification Create(NotificationMessage message, UserProfileSettings settings)
        {
            if (!registry.TryGetValue(message.Event, out var messageType))
            {
                throw new InvalidOperationException($"{message.Event} event is not supported");
            }

            var modelType    = messageType.BaseType.GetGenericArguments().First();
            var model        = DynamicExtensions.ToStatic(modelType, message.Parameters);
            var notification = (IEmailNotification)Activator.CreateInstance(messageType, settings.Email, settings.FullName, model);

            SetContent(modelType.Name, settings.Language, notification);

            return(notification);
        }
Esempio n. 15
0
        public ActionResult Settings()
        {
            if (Session["loggedUser"] != null)
            {
                SessionControl      sessionControl = (SessionControl)Session["loggedUser"];
                List <PrivacyRules> userRulesList  = new List <PrivacyRules>();
                UserAccount         userAccount    = null;

                using (var db = new BoardGamesDBEntities())
                {
                    Users user = db.Users.FirstOrDefault(u => u.Id == sessionControl.Id);
                    userAccount = new UserAccount()
                    {
                        Key      = user.Id,
                        Email    = user.Email,
                        Login    = user.Login,  // do not pass password - for safety
                        Name     = user.Name,
                        Surname  = user.Surname,
                        Sex      = user.Sex,
                        Birthday = user.Birthday,
                        Avatar   = user.Avatar
                    };

                    foreach (UsersPrivacyPolicy rule in db.UsersPrivacyPolicy.Where(p => p.UserId == user.Id).ToList())
                    {
                        userRulesList.Add(
                            new PrivacyRules()
                        {
                            RuleDescription = db.UsersPrivacyPolicyList.FirstOrDefault(p => p.Id == rule.RuleId).Description,
                            RuleLevel       = rule.RuleLevel
                        }
                            );
                    }
                }

                // Create final model
                UserProfileSettings userProfileSettings = new UserProfileSettings()
                {
                    UserInformation   = userAccount,
                    UserPrivacyPolicy = userRulesList
                };

                return(View(userProfileSettings));
            }

            // When user is not logged
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 16
0
        public UserProfileDialog(IActionExecutor actionExec,
                                 UploadWizardPolicy policy,
                                 IUserProfileSettingsUtils userProfileUtils)
        {
            _actionExec = actionExec;
            _policy     = policy;

            InitializeComponent();

            _userProfileSettingsUtils = userProfileUtils;
            _userProfileSettings      = _userProfileSettingsUtils.GetSettings();

            var userProfileContext = new UserProfileContext(_userProfileSettings, _userProfileSettingsUtils);

            DataContext = userProfileContext;
        }
Esempio n. 17
0
        /// <summary>
        /// 转换为userProfileSettings用于数据库存储
        /// </summary>
        public UserProfileSettings AsUserProfileSettings()
        {
            UserProfileSettings userProfileSettings = DIContainer.Resolve <IUserProfileSettingsManager>().GetUserProfileSettings();

            userProfileSettings.IntegrityProportions[0] = Avatar ?? 20;
            userProfileSettings.IntegrityProportions[1] = Birthday ?? 10;
            userProfileSettings.IntegrityProportions[2] = NowArea ?? 10;
            userProfileSettings.IntegrityProportions[3] = HomeArea ?? 10;
            userProfileSettings.IntegrityProportions[4] = IM ?? 10;
            userProfileSettings.IntegrityProportions[5] = Mobile ?? 0;
            userProfileSettings.IntegrityProportions[6] = EducationExperience ?? 15;
            userProfileSettings.IntegrityProportions[7] = WorkExperience ?? 15;
            userProfileSettings.IntegrityProportions[8] = Introduction ?? 10;
            userProfileSettings.MinIntegrity            = MinIntegrity ?? 50;
            userProfileSettings.MaxPersonTag            = MaxPersonTag ?? 10;
            return(userProfileSettings);
        }
Esempio n. 18
0
        public ActionResult Edit(UserProfileSettings userp)
        {
            User user = _userRepo.FindByID(userp.UserID);

            if (ModelState.IsValid && sv.isValidSex(userp.Sex))
            {
                user.ID              = userp.UserID;
                user.FirstName       = userp.FirstName;
                user.LastName        = userp.LastName;
                user.BirthDate       = userp.BirthDate;
                user.Email           = userp.Email;
                user.IsUsingGravatar = userp.IsUsingGravatar;
                user.Sex             = userp.Sex;
                _userRepo.Update(user);
                return(RedirectToAction("Index"));
            }
            return(View(userp));
        }
Esempio n. 19
0
        public void SetUp()
        {
            _mockIoUtils = new Mock <IIoUtils>();
            Registry.RegisterComponent(_mockIoUtils.Object);

            _mockPublisherUtils = new Mock <IPublisherUtils>();
            Registry.RegisterComponent(_mockPublisherUtils.Object);

            _mockLogger = new Mock <ILogger>();

            _mockExporter = new Mock <IExporter>();

            _mockLogs = new List <Mock <ILog> > {
                new Mock <ILog>(), new Mock <ILog>(), new Mock <ILog>()
            };

            _mockLogFileManager = new Mock <ILogManager>();
            _mockLogFileManager.Setup(mgr => mgr.Logs).Returns(_mockLogs.Select(m => m.Object));

            _mockSettingStore = new Mock <ISettingsStore>();
            _mockSettingStore.Setup(store => store.GetSettings <UploadSettings>()).Returns(new UploadSettings());
            _exportSettings = new ExportSettings {
                UploadUrl = TestUploadUrl
            };
            _userSettings          = new UserProfileSettings();
            _anonymizationSettings = new AnonymizationSettings();
            _mockSettingStore.Setup(store => store.GetSettings <ExportSettings>()).Returns(_exportSettings);
            _mockSettingStore.Setup(store => store.GetSettings <UserProfileSettings>()).Returns(_userSettings);
            _mockSettingStore.Setup(store => store.GetSettings <AnonymizationSettings>())
            .Returns(_anonymizationSettings);
            _mockSettingStore.Setup(store => store.UpdateSettings(It.IsAny <Action <ExportSettings> >()))
            .Callback <Action <ExportSettings> >(update => update(_exportSettings));

            _testDateUtils = new TestDateUtils();
            _uut           = new UploadWizardContext(
                _mockExporter.Object,
                _mockLogFileManager.Object,
                _mockSettingStore.Object,
                _testDateUtils,
                _mockLogger.Object);

            _errorNotificationHelper   = _uut.ErrorNotificationRequest.NewTestHelper();
            _successNotificationHelper = _uut.SuccessNotificationRequest.NewTestHelper();
        }
Esempio n. 20
0
        public ActionResult Edit(Guid id)
        {
            User user = _userRepo.FindByID(id);

            if (user != null)
            {
                UserProfileSettings ups = new UserProfileSettings();
                ups.UserID          = user.ID;
                ups.FirstName       = user.FirstName;
                ups.LastName        = user.LastName;
                ups.BirthDate       = user.BirthDate;
                ups.Email           = user.Email;
                ups.IsUsingGravatar = user.IsUsingGravatar;
                ups.Sex             = user.Sex;

                return(View(ups));
            }
            return(HttpNotFound());
        }
Esempio n. 21
0
        public void UpdateRecording(string detail, [FromBody] JobScheduleData data)
        {
            // Parameter analysieren
            VCRJob job;
            var    schedule = ServerRuntime.ParseUniqueWebId(detail, out job);

            // Validate
            if (schedule == null)
            {
                throw new ArgumentException("Job or Schedule not found");
            }

            // Take the new job data
            var newJob      = data.Job.CreateJob(job.UniqueID.Value);
            var newSchedule = data.Schedule.CreateSchedule(schedule.UniqueID.Value, newJob);

            // All exceptions still active
            var activeExceptions     = data.Schedule.Exceptions ?? Enumerable.Empty <PlanException>();
            var activeExceptionDates = new HashSet <DateTime>(activeExceptions.Select(exception => exception.ExceptionDate));

            // Copy over all exceptions
            newSchedule.Exceptions.AddRange(schedule.Exceptions.Where(exception => activeExceptionDates.Contains(exception.When)));

            // See if we can use it
            if (!newSchedule.IsActive)
            {
                throw new ArgumentException(Properties.Resources.ScheduleInPast);
            }

            // Copy all schedules expect the one wie founr
            newJob.Schedules.AddRange(job.Schedules.Where(oldSchedule => !ReferenceEquals(oldSchedule, schedule)));

            // Add the updated variant
            newJob.Schedules.Add(newSchedule);

            // Send to persistence
            ServerRuntime.VCRServer.UpdateJob(newJob, newSchedule.UniqueID.Value);

            // Update recently used channels
            UserProfileSettings.AddRecentChannel(data.Job.Source);
            UserProfileSettings.AddRecentChannel(data.Schedule.Source);
        }
        public void Setup()
        {
            _kaveSettings    = new KaVESettings();
            _anonSettings    = new AnonymizationSettings();
            _profileSettings = new UserProfileSettings();
            _exportSettings  = new ExportSettings();
            _profileUtils    = Mock.Of <IUserProfileSettingsUtils>();

            _store = Mock.Of <ISettingsStore>();
            Mock.Get(_store).Setup(ss => ss.GetSettings <KaVESettings>()).Returns(_kaveSettings);
            Mock.Get(_store).Setup(s => s.GetSettings <AnonymizationSettings>()).Returns(_anonSettings);
            Mock.Get(_store).Setup(s => s.GetSettings <UserProfileSettings>()).Returns(_profileSettings);
            Mock.Get(_store).Setup(s => s.GetSettings <ExportSettings>()).Returns(_exportSettings);

            _windows = Mock.Of <ISimpleWindowOpener>();

            // setting valid values that should not be notified
            _anonSettings.RemoveSessionIDs = false;
            _profileSettings.ProfileId     = "x";
            _exportSettings.UploadUrl      = "http://upload.kave.cc/";
        }
Esempio n. 23
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="userProfileSettings">用户资料设置</param>
 /// <param name="userSettings">用户设置</param>
 /// <param name="inviteFriendSettings">邀请朋友设置</param>
 public UserSettingsEditModel(UserProfileSettings userProfileSettings, UserSettings userSettings, InviteFriendSettings inviteFriendSettings)
 {
     if (userSettings != null)
     {
         RegistrationMode  = userSettings.RegistrationMode;
         AccountActivation = userSettings.AccountActivation;
         EnableNotActivatedUsersToLogin = userSettings.EnableNotActivatedUsersToLogin;
         EnableTrackAnonymous           = userSettings.EnableTrackAnonymous;
         UserOnlineTimeWindow           = userSettings.UserOnlineTimeWindow;
         UserPasswordFormat             = userSettings.UserPasswordFormat;
         AutomaticModerated             = userSettings.AutomaticModerated;
         NoModeratedUserPoint           = userSettings.NoModeratedUserPoint;
         EnableNickname        = userSettings.EnableNickname;
         DisplayNameType       = userSettings.DisplayNameType;
         DisallowedUserNames   = userSettings.DisallowedUserNames;
         MyHomePageAsSiteEntry = userSettings.MyHomePageAsSiteEntry;
     }
     if (userProfileSettings != null)
     {
         Avatar              = userProfileSettings.IntegrityProportions[0];
         Birthday            = userProfileSettings.IntegrityProportions[1];
         NowArea             = userProfileSettings.IntegrityProportions[2];
         HomeArea            = userProfileSettings.IntegrityProportions[3];
         IM                  = userProfileSettings.IntegrityProportions[4];
         Mobile              = userProfileSettings.IntegrityProportions[5];
         EducationExperience = userProfileSettings.IntegrityProportions[6];
         WorkExperience      = userProfileSettings.IntegrityProportions[7];
         Introduction        = userProfileSettings.IntegrityProportions[8];
         MaxPersonTag        = userProfileSettings.MaxPersonTag;
         MinIntegrity        = userProfileSettings.MinIntegrity;
     }
     if (inviteFriendSettings != null)
     {
         AllowInvitationCodeUseOnce     = inviteFriendSettings.AllowInvitationCodeUseOnce;
         InvitationCodeTimeLiness       = inviteFriendSettings.InvitationCodeTimeLiness;
         InvitationCodeUnitPrice        = inviteFriendSettings.InvitationCodeUnitPrice;
         DefaultUserInvitationCodeCount = inviteFriendSettings.DefaultUserInvitationCodeCount;
     }
 }
Esempio n. 24
0
        public string CreateNewRecording(string detail, [FromBody] JobScheduleData data)
        {
            // Parameter analysieren
            VCRJob job;

            ServerRuntime.ParseUniqueWebId(detail + Guid.NewGuid().ToString("N"), out job);

            // Validate
            if (job == null)
            {
                throw new ArgumentException("Job not found");
            }

            // Take the new job data
            var newJob      = data.Job.CreateJob(job.UniqueID.Value);
            var newSchedule = data.Schedule.CreateSchedule(newJob);

            // See if we can use it
            if (!newSchedule.IsActive)
            {
                throw new ArgumentException(Properties.Resources.ScheduleInPast);
            }

            // Add all existing
            newJob.Schedules.AddRange(job.Schedules);

            // Add the new one
            newJob.Schedules.Add(newSchedule);

            // Send to persistence
            ServerRuntime.VCRServer.UpdateJob(newJob, newSchedule.UniqueID.Value);

            // Update recently used channels
            UserProfileSettings.AddRecentChannel(data.Job.Source);
            UserProfileSettings.AddRecentChannel(data.Schedule.Source);

            // Report
            return(ServerRuntime.GetUniqueWebId(newJob, newSchedule));
        }
Esempio n. 25
0
        public void SetUp()
        {
            _userSettings = new UserProfileSettings
            {
                ProfileId = ""
            };
            _updatedProperties = new List <string>();


            var newGuid = Guid.NewGuid();

            _someGuid = newGuid.ToString();
            var rnd = Mock.Of <IRandomizationUtils>();

            Mock.Get(rnd).Setup(r => r.GetRandomGuid()).Returns(newGuid);

            _userSettingsUtil = Mock.Of <IUserProfileSettingsUtils>();
            Mock.Get(_userSettingsUtil).Setup(u => u.CreateNewProfileId()).Returns(_someGuid);

            _sut = new UserProfileContext(_userSettings, _userSettingsUtil);

            _sut.PropertyChanged += (sender, args) => { _updatedProperties.Add(args.PropertyName); };
        }
Esempio n. 26
0
        public void Setup()
        {
            _userProfileSettings     = new UserProfileSettings();
            _userProfileSettingsUtil = Mock.Of <IUserProfileSettingsUtils>();

            _mockSettingsStore = new Mock <ISettingsStore>();
            _windowCreator     = Mock.Of <IUploadWizardWindowCreator>();
            _mockLogManager    = new Mock <ILogManager>();

            _mockSettingsStore.Setup(settingStore => settingStore.GetSettings <UserProfileSettings>())
            .Returns(_userProfileSettings);
            _exportSettings = new ExportSettings();
            _mockSettingsStore.Setup(settingStore => settingStore.GetSettings <ExportSettings>())
            .Returns(_exportSettings);


            Registry.RegisterComponent(_userProfileSettingsUtil);
            Registry.RegisterComponent(_mockSettingsStore.Object);
            Registry.RegisterComponent(_windowCreator);
            Registry.RegisterComponent(_mockLogManager.Object);

            _uut = new UploadWizardAction();
        }
Esempio n. 27
0
        /// <summary>
        /// 显示头像
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <param name="avatarSizeType">头像尺寸类别</param>
        /// <param name="link">链接到用户空间的地址</param>
        /// <param name="navigateTarget">链接类型</param>
        /// <param name="enableCachingInClient">是否允许在客户端缓存</param>
        /// <param name="htmlAttributes">html属性,例如:new RouteValueDictionary{{"Class","editor"},{"width","90%"}}</param>
        /// <returns></returns>
        public static MvcHtmlString ShowUserAvatar(this HtmlHelper htmlHelper, IUser user, string link, AvatarSizeType avatarSizeType = AvatarSizeType.Medium, HyperLinkTarget navigateTarget = HyperLinkTarget._blank, bool enableCachingInClient = true, RouteValueDictionary htmlAttributes = null, bool isShowUserCard = true, bool isShowTitle = false)
        {
            string avatarUrl = SiteUrls.Instance().UserAvatarUrl(user, avatarSizeType, enableCachingInClient);

            TagBuilder img = new TagBuilder("img");

            if (htmlAttributes != null)
            {
                img.MergeAttributes(htmlAttributes);
            }

            img.MergeAttribute("src", avatarUrl);
            if (user != null)
            {
                img.MergeAttribute("alt", user.DisplayName);
                if (isShowTitle)
                {
                    img.MergeAttribute("title", user.DisplayName);
                }
            }

            IUserProfileSettingsManager userProfileSettingsManager = DIContainer.Resolve <IUserProfileSettingsManager>();
            UserProfileSettings         userProfileSettings        = userProfileSettingsManager.GetUserProfileSettings();

            TagBuilder div = new TagBuilder("div");

            switch (avatarSizeType)
            {
            case AvatarSizeType.Big:
                img.MergeAttribute("width", userProfileSettings.AvatarWidth.ToString());
                div.AddCssClass("tn-avatar-big");
                break;

            case AvatarSizeType.Medium:
                img.MergeAttribute("width", userProfileSettings.MediumAvatarWidth.ToString());
                div.AddCssClass("tn-avatar-medium");
                break;

            case AvatarSizeType.Small:
                img.MergeAttribute("width", userProfileSettings.SmallAvatarWidth.ToString());
                div.AddCssClass("tn-avatar");
                break;

            case AvatarSizeType.Micro:
                img.MergeAttribute("width", userProfileSettings.MicroAvatarWidth.ToString());
                div.AddCssClass("tn-avatar-mini");
                break;
            }

            if (!string.IsNullOrEmpty(link) && user != null)
            {
                TagBuilder a = new TagBuilder("a");
                a.MergeAttribute("href", link);

                if (navigateTarget != HyperLinkTarget._self)
                {
                    a.MergeAttribute("target", navigateTarget.ToString());
                }

                if (isShowUserCard)
                {
                    a.MergeAttribute("plugin", "tipsyHoverCard");
                    a.MergeAttribute("data-user-card-url", SiteUrls.Instance()._UserCard(user.UserId));
                    a.MergeAttribute("outerclass", "tn-user-card");
                }

                a.InnerHtml   = img.ToString(TagRenderMode.SelfClosing);
                div.InnerHtml = a.ToString();
                return(new MvcHtmlString(div.ToString()));
            }
            else
            {
                div.InnerHtml = img.ToString(TagRenderMode.SelfClosing);
                return(new MvcHtmlString(div.ToString()));
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Aktualisiert die Einstellungen des Anwenders.
        /// </summary>
        public void Update()
        {
            // Direct copy
            UserProfileSettings.NoHibernateOnAbort = NoHibernateOnAbort;
            UserProfileSettings.BackToEPG          = BackToGuideAfterAdd;
            UserProfileSettings.UseSubTitles       = PreferSubtitles;
            UserProfileSettings.UseMP2             = PreferAllLanguages;
            UserProfileSettings.UseTTX             = PreferVideotext;
            UserProfileSettings.UseAC3             = PreferDolby;

            // A bit more work on flag groups
            switch (DefaultSourceTypeSelector ?? string.Empty)
            {
            case "R": UserProfileSettings.Radio = true; UserProfileSettings.Television = false; break;

            case "T": UserProfileSettings.Radio = false; UserProfileSettings.Television = true; break;

            case "RT": UserProfileSettings.Radio = true; UserProfileSettings.Television = true; break;
            }
            switch (DefaultSourceEncryptionSelector ?? string.Empty)
            {
            case "F": UserProfileSettings.FreeTV = true; UserProfileSettings.PayTV = false; break;

            case "P": UserProfileSettings.FreeTV = false; UserProfileSettings.PayTV = true; break;

            case "FP": UserProfileSettings.FreeTV = true; UserProfileSettings.PayTV = true; break;
            }

            // Numbers are copied after check
            if (DaysToShowInPlan >= 1)
            {
                if (DaysToShowInPlan <= 50)
                {
                    UserProfileSettings.DaysToShow = DaysToShowInPlan;
                }
            }
            if (RowsInRecentSources >= 1)
            {
                if (RowsInRecentSources <= 50)
                {
                    UserProfileSettings.MaxRecentChannels = RowsInRecentSources;
                }
            }
            if (GuideStartEarly >= 0)
            {
                if (GuideStartEarly <= 240)
                {
                    UserProfileSettings.EPGPreTime = GuideStartEarly;
                }
            }
            if (GuideEndLate >= 0)
            {
                if (GuideEndLate <= 240)
                {
                    UserProfileSettings.EPGPostTime = GuideEndLate;
                }
            }
            if (RowsInGuide >= 10)
            {
                if (RowsInGuide <= 100)
                {
                    UserProfileSettings.EPGEntries = RowsInGuide;
                }
            }

            // Store
            UserProfileSettings.Update();
        }
Esempio n. 29
0
 public UserProfileContext(UserProfileSettings userProfileSettings, IUserProfileSettingsUtils util)
 {
     _userProfileSettings = userProfileSettings;
     _util = util;
 }
 public void SaveUserProfileSettings(UserProfileSettings userProfileSettings)
 {
     repository.Save(userProfileSettings);
 }