コード例 #1
0
ファイル: UserProfileCache.cs プロジェクト: MulderFox/Main
        public static void ProcessAccessPayments(DefaultContext db)
        {
            DateTime currentDbDate = DateTime.Now.Date.AddDays(1).AddSeconds(-1);

            // Zkontrolovat zaplacené CLA Trial účty
            CheckClaAccessTrialUsers(db, currentDbDate);

            // Zkontrolovat zaplacené účty
            CheckClaAccessUsers(db, currentDbDate);

            db.SaveChanges();

            // Upozornění na 1 měsíc před expirací.
            CheckNotificationClaUsers(db, currentDbDate, ClaAccessNotification.Monthly);

            // Upozornění na 14 dní, 3 dny před expirací a v den expirace.
            var claAccessNotifications = new[] { ClaAccessNotification.Fortnightly, ClaAccessNotification.ThreeDays, ClaAccessNotification.Current };
            foreach (ClaAccessNotification claAccessNotification in claAccessNotifications)
            {
                CheckNotificationClaUsers(db, currentDbDate, claAccessNotification);
            }

            // Upozornit čerstvě zablokované účty
            CheckNotificationNewBlockedClaUsers(db, currentDbDate);
        }
コード例 #2
0
ファイル: UserProfileCache.cs プロジェクト: MulderFox/Main
        public static ModelStateDictionary Register(DefaultContext db, Register model, out RegisterResult registerResult)
        {
            var modelStateDictionary = new ModelStateDictionary();

            // Attempt to register the user
            try
            {
                var propertyValues = new
                {
                    model.FirstName,
                    model.LastName,
                    model.Title,
                    model.City,
                    model.DistrictId,
                    model.PhoneNumberPrefix1Id,
                    model.PhoneNumber1,
                    model.PhoneNumberPrefix2Id,
                    model.PhoneNumber2,
                    model.Email1,
                    model.Email2,
                    model.GoogleCredentialsJson,
                    model.GoogleCalendarId,
                    model.PremiumMembershipGranted,
                    model.AccessGranted,
                    model.Ca,
                    model.Presenting,
                    model.MspCoach,
                    model.RegistrarId,
                    Active = true,
                    model.LyonessId,
                    model.Note,
                    model.Tasks,
                    model.Skype,
                    model.SmsEmail,
                    UseMail = true,
                    UseSms = true,
                    UseGoogleCalendar = true,
                    model.ClaAccessExpired,
                    model.ClaAccessYearlyAccessCZK,
                    model.ClaAccessYearlyAccessEUR,
                    model.ClaAccessYearlyAccessUSD,
                    ClaAccessCurrency = model.CurrencyType,
                    model.ClaAccessTrial,
                    model.ClaAccessFixCurrencyChange,
                    model.LCID
                };
                string password = Cryptography.GetRandomPassword();
                WebSecurity.CreateUserAndAccount(model.UserName, password, propertyValues);
                Roles.AddUserToRole(model.UserName, UserProfile.GetRoleTypeDbName(RoleType.AuthGuest));

                string textBody = String.Format(MailResource.AccountController_Register_TextBody, model.UserName, password, Url.GetWebRootUrl());
                if (!Mail.SendEmail(model.Email1, MailResource.AccountController_Register_Subject, textBody, true, true))
                {
                    registerResult = RegisterResult.CannotSendRegisterEmail;
                    return modelStateDictionary;
                }
            }
            catch (MembershipCreateUserException e)
            {
                string message = String.Format("Register New User '{0}' - {1}", model.UserName, e.Message);
                Logger.SetLog(message);
                registerResult = RegisterResult.Failed;
                modelStateDictionary.AddModelError(EmptyField, DecodeMembershipCreateStatus(e.StatusCode));
                return modelStateDictionary;
            }
            catch (Exception e)
            {
                Logger.SetLog(e);
                registerResult = RegisterResult.Failed;
                modelStateDictionary.AddModelError(EmptyField, ValidationResource.Global_UnexpectedException_ErrorMessage);
                return modelStateDictionary;
            }

            registerResult = RegisterResult.Ok;
            return modelStateDictionary;
        }