Exemplo n.º 1
0
        public void SendApplicationEmailToDeveloper(Application application)
        {
            var sysEMail  = PreferenceService.GetTyped <EmailInfo>(Preference.SYSTEM_EMAIL);
            var mail      = PrepareDefaultMail(sysEMail);
            var developer = application.Developer;

            switch (application.State)
            {
            case ApplicationStateEnum.Approved:
                mail.Subject = PreferenceService.Get(Preference.APPLICATION_APPROVED_EMAIL_SUBJECT).Value;
                var confirmationKey = developer.User.ConfirmationKey;
                var url             = string.Format(developerConfirmUrlFormat, PreferenceService.Get(Preference.APPLICATION_URL).Value
                                                    , confirmationKey, application.Id);
                mail.Body = string.Format(PreferenceService.Get(Preference.APPLICATION_APPROVED_EMAIL_BODY).Value,
                                          application.Name, developer.Name, url);
                break;

            case ApplicationStateEnum.Rejected:
                mail.Subject = PreferenceService.Get(Preference.APPLICATION_REJECTED_EMAIL_SUBJECT).Value;
                mail.Body    = string.Format(PreferenceService.Get(Preference.APPLICATION_REJECTED_EMAIL_BODY).Value,
                                             application.Name, developer.DisplayName);
                break;

            default: throw new ChalkableException(ChlkResources.EMAIL_INCORRECT_APP_STATE);
            }
            if (EmailTools.IsValidEmailAddress(developer.Email))
            {
                mail.To.Add(developer.Email);
            }
            SendMail(mail, sysEMail);
        }
Exemplo n.º 2
0
        public Guid?GetAssessmentId()
        {
            var  id = PreferenceService.Get(Context.AssessmentEnabled || Context.SCEnabled ? Preference.ASSESSMENT_APLICATION_ID : null).Value;
            Guid res;

            return(Guid.TryParse(id, out res) ? res : (Guid?)null);
        }
Exemplo n.º 3
0
        private string GetBaseUrlByRole(Person person, string baseUrl)
        {
            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = PreferenceService.Get(Preference.APPLICATION_URL).Value;
            }
            var url = UrlTools.UrlCombine(baseUrl, "/Home/") + "{0}";

            if (person.RoleRef == CoreRoles.SUPER_ADMIN_ROLE.Id)
            {
                return(string.Format(url, ROLE_SYSADMIN));
            }
            if (person.RoleRef == CoreRoles.DISTRICT_ADMIN_ROLE.Id)
            {
                return(string.Format(url, ROLE_ADMIN));
            }
            if (person.RoleRef == CoreRoles.TEACHER_ROLE.Id)
            {
                return(string.Format(url, ROLE_TEACHER));
            }
            if (person.RoleRef == CoreRoles.STUDENT_ROLE.Id)
            {
                return(string.Format(url, ROLE_STUDENT));
            }
            if (person.RoleRef == CoreRoles.PARENT_ROLE.Id)
            {
                return(string.Format(url, ROLE_PARENT));
            }
            if (person.RoleRef == CoreRoles.CHECKIN_ROLE.Id)
            {
                return(string.Format(url, ROLE_CHECKIN));
            }

            throw new UnknownRoleException();
        }
Exemplo n.º 4
0
        public Guid?GetMiniQuizAppicationId()
        {
            var key = ApplicationSecurity.HasAssessmentEnabled(Context)
                    ? Preference.ASSESSMENT_APLICATION_ID
                    : null;

            Guid res;

            return(key != null ? (Guid.TryParse(PreferenceService.Get(key).Value, out res) ? res : (Guid?)null) : null);
        }
Exemplo n.º 5
0
        private District PrepareCommonViewData()
        {
            District district = null;

            if (Context.DistrictId.HasValue && Context.SchoolLocalId.HasValue)
            {
                district = MasterLocator.DistrictService.GetByIdOrNull(Context.DistrictId.Value);
                if (Context.DeveloperId != null)
                {
                    ViewData[ViewConstants.IS_DEV] = true;
                }
                if (district.IsDemoDistrict)
                {
                    ViewData[ViewConstants.STUDENT_ROLE]        = CoreRoles.STUDENT_ROLE.Name;
                    ViewData[ViewConstants.TEACHER_ROLE]        = CoreRoles.TEACHER_ROLE.Name;
                    ViewData[ViewConstants.DISTRICT_ADMIN_ROLE] = CoreRoles.DISTRICT_ADMIN_ROLE.Name;

                    ViewData[ViewConstants.DEMO_PICTURE_DISTRICT_REF] = DEMO_PICTURE_DISTRICT_REF;
                    ViewData[ViewConstants.IS_DEMO_DISTRICT]          = true;
                }
                ViewData[ViewConstants.LAST_SYNC_DATE] = district.LastSync.HasValue
                    ? district.LastSync.Value.ToString("yyyy/MM/dd hh:mm:ss")
                    : "";
                ViewData[ViewConstants.DISTRICT_ID] = district.Id.ToString();

                var messagingSettings = MessagingSettingsViewData.Create(MasterLocator.SchoolService.GetDistrictMessaginSettings(Context.DistrictId.Value));
                PrepareJsonData(messagingSettings, ViewConstants.MESSAGING_SETTINGS);

                //TODO : maybe added this to startup data ... only needs for school persons
                var school = SchoolLocator.SchoolService.GetSchool(Context.SchoolLocalId.Value);
                ViewData[ViewConstants.SCHOOL_NAME] = school.Name;
            }
            ViewData[ViewConstants.CURRENT_USER_ROLE_ID]   = Context.RoleId;
            ViewData[ViewConstants.ROLE_NAME]              = Context.Role.LoweredName;
            ViewData[ViewConstants.AZURE_PICTURE_URL]      = PictureService.GetPicturesRelativeAddress();
            ViewData[ViewConstants.DEMO_AZURE_PICTURE_URL] = PictureService.GeDemoPicturesRelativeAddress();
            ViewData[ViewConstants.CURR_SCHOOL_YEAR_ID]    = GetCurrentSchoolYearId();
            ViewData[ViewConstants.VERSION]                  = CompilerHelper.Version;
            ViewData[ViewConstants.CROCODOC_API_URL]         = PreferenceService.Get(Preference.CROCODOC_URL).Value;
            ViewData[ViewConstants.SERVER_TIME]              = Context.NowSchoolTime.ToString(DATE_TIME_FORMAT);
            ViewData[ViewConstants.SCHOOL_YEAR_SERVER_TIME]  = Context.NowSchoolYearTime.ToString(DATE_TIME_FORMAT);
            ViewData[ViewConstants.STUDY_CENTER_ENABLED]     = Context.SCEnabled;
            ViewData[ViewConstants.ASSESSMENT_ENABLED]       = Context.AssessmentEnabled;
            ViewData[ViewConstants.MESSAGING_DISABLED]       = Context.MessagingDisabled;
            ViewData[ViewConstants.ASSESSMENT_APLICATION_ID] = MasterLocator.ApplicationService.GetAssessmentId();
            ViewData[ViewConstants.SIS_API_VERSION]          = Context.SisApiVersion;
            ViewData[ViewConstants.USER_LOGIN]               = Context.Login;
            ViewData[ViewConstants.LOGIN_TIME_OUT]           = Context.LoginTimeOut;

            var leParams = SchoolLocator.LeService.GetLEParams();

            PrepareJsonData(leParams, ViewConstants.LE_PARAMS);
            PrepareJsonData(PersonClaimViewData.Create(Context.Claims), ViewConstants.USER_CLAIMS);
            return(district);
        }
Exemplo n.º 6
0
        private static bool IsDemoLogin(string userLogin)
        {
            var logins = new[]
            {
                PreferenceService.Get(Preference.DEMO_SCHOOL_ADMIN_EDIT).Value,
                PreferenceService.Get(Preference.DEMO_SCHOOL_ADMIN_GRADE).Value,
                PreferenceService.Get(Preference.DEMO_SCHOOL_ADMIN_VIEW).Value,
                PreferenceService.Get(Preference.DEMO_SCHOOL_TEACHER).Value,
                PreferenceService.Get(Preference.DEMO_SCHOOL_STUDENT).Value
            };

            return(logins.Any(login => String.Equals(userLogin, login, StringComparison.CurrentCultureIgnoreCase)));
        }
Exemplo n.º 7
0
        public static User GetDemoUser(string login)
        {
            var userRoles = new Dictionary <string, string>
            {
                { PreferenceService.Get("demoschool" + CoreRoles.TEACHER_ROLE.LoweredName).Value, CoreRoles.TEACHER_ROLE.LoweredName },
                { PreferenceService.Get("demoschool" + CoreRoles.STUDENT_ROLE.LoweredName).Value, CoreRoles.STUDENT_ROLE.LoweredName }
            };

            var userLogin = login.Substring(login.IndexOf(DEMO_USER_PREFIX, StringComparison.InvariantCultureIgnoreCase));
            var prefix    = login.Substring(0, login.IndexOf(DEMO_USER_PREFIX, StringComparison.InvariantCultureIgnoreCase));

            if (userRoles.ContainsKey(userLogin))
            {
                var role = userRoles[userLogin];
                return(GetDemoUser(role, prefix));
            }
            return(null);
        }
Exemplo n.º 8
0
 public void SendChangeEmailToDeveloper(Developer developer, string oldEmail, string newEmail)
 {
     if (!IsAutogenerated(oldEmail))
     {
         var sysEMail   = PreferenceService.GetTyped <EmailInfo>(Preference.SYSTEM_EMAIL);
         var personMail = oldEmail;
         var mail       = PrepareDefaultMail(sysEMail);
         if (EmailTools.IsValidEmailAddress(personMail))
         {
             mail.To.Add(personMail);
         }
         else
         {
             Trace.TraceWarning(ChlkResources.ERR_EMAIL_INVALID, personMail);
             return;
         }
         var bodyTemplate = PreferenceService.Get(Preference.EMAIL_CHANGE_EMAIL_BODY).Value;
         mail.Body = string.Format(bodyTemplate, developer.DisplayName, newEmail);
         SendMail(mail, sysEMail);
     }
 }
Exemplo n.º 9
0
 public string GetCrocodocApiUrl()
 {
     return(PreferenceService.Get(Preference.CROCODOC_API_URL).Value);
 }
Exemplo n.º 10
0
 public string GetStrorageUrl()
 {
     return(PreferenceService.Get(Preference.CROCODOC_URL).Value);
 }
Exemplo n.º 11
0
 public string GetToken()
 {
     return(PreferenceService.Get(Preference.CROCODOC_TOKEN).Value);
 }
Exemplo n.º 12
0
 public static string BuildDemoUserName(string roleName, string prefix)
 {
     return(prefix + PreferenceService.Get("demoschool" + roleName.ToLower()).Value);
 }
Exemplo n.º 13
0
        public async Task <JsonResult> Get()
        {
            PreferenceService service = new PreferenceService(serviceProvider);

            return(Json(await service.Get(User.Identity as ClaimsIdentity)));
        }