Example #1
0
        public void initData()
        {
            //Confirmation all teachers, grades and classes have loaded.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            //confirmation all course groups and locations has loaded.
            if (!CourseWeekViewModel.getInstance().mIsInitialized)
            {
                CourseWeekViewModel.getInstance().worker_initDataFromDatabase(false);
            }

            //Get the current user's id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];
            int         basicid     = 0;

            if (currentUser != null)
            {
                basicid = currentUser.id;
            }
            selectedClassid = DatabaseHelper.getClassIdByHeadTeacherId(basicid);
            classCourses    = DatabaseHelper.getClassCoursesByTeacherId(basicid);

            //find the class which the teacher has teached.
            foreach (ClassCourse cc in classCourses)
            {
                classes.Add(ClassViewModel.getInstance().getClassById(cc.classid));
            }
            courseGroups     = getCourseGroupsByClassId(selectedClassid);
            selectedCourseid = courseGroups[0].id;

            //start load  course cards.
            currentCourseCards = DatabaseHelper.getAllCourseCards(selectedClassid, selectedCourseid);
        }
        public IEnumerable <ContentPropertyBasic> Resolve(IMember source, MemberBasic destination, IEnumerable <ContentPropertyBasic> destMember, ResolutionContext context)
        {
            var umbracoContext = _umbracoContextAccessor.UmbracoContext;

            if (umbracoContext == null)
            {
                throw new InvalidOperationException("Cannot resolve value without an UmbracoContext available");
            }

            var result = Mapper.Map <IEnumerable <Property>, IEnumerable <ContentPropertyBasic> >(
                // Sort properties so items from different compositions appear in correct order (see U4-9298). Map sorted properties.
                source.Properties.OrderBy(prop => prop.PropertyType.SortOrder))
                         .ToList();

            var memberType = _memberTypeService.Get(source.ContentTypeId);

            //now update the IsSensitive value
            foreach (var prop in result)
            {
                //check if this property is flagged as sensitive
                var isSensitiveProperty = memberType.IsSensitiveProperty(prop.Alias);
                //check permissions for viewing sensitive data
                if (isSensitiveProperty && umbracoContext.Security.CurrentUser.HasAccessToSensitiveData() == false)
                {
                    //mark this property as sensitive
                    prop.IsSensitive = true;
                    //clear the value
                    prop.Value = null;
                }
            }
            return(result);
        }
Example #3
0
        public void initData()
        {
            initWeekNo();
            //Judge ClassViewModel is initilized to get all teachers, all grades and all classes.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            //init selected grade id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];

            if (currentUser != null)
            {
                //set selectedGradeId;
                int basicId = currentUser.id;
                selectedClassId = DatabaseHelper.getClassIdByTeacherId(basicId);
            }
            if (selectedClassId == -1)
            {
                selectedClassId = ClassViewModel.getInstance().allClasses[0].id;
            }

            //init courseGroups.
            allCourseGroups = DatabaseHelper.getallCourseGroups();
            readWeeklyReportItemsFromDataBase(-1);
        }
        public MainWindow()
        {
            InitializeComponent();
            MemberBasic basic = (MemberBasic)Application.Current.Properties["currentUser"];

            if (basic != null)
            {
                userNameTextBlock.Text = basic.engname;
            }
            contentPanelFrame = (Frame)FindName("contentPanel");
            contentPanelFrame.NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden;
        }
        //TODO: SD: I can't remember why this mapping is here?
        // Umbraco.Code.MapAll -Udi -Properties -ParentId -Path -SortOrder -Edited -Updater
        // Umbraco.Code.MapAll -Trashed -Alias -ContentTypeId -ContentTypeAlias -VariesByCulture
        private void Map(MembershipUser source, MemberBasic target, MapperContext context)
        {
            target.CreateDate = source.CreationDate;
            target.Email = source.Email;
            target.Icon = Constants.Icons.Member;
            target.Id = int.MaxValue;
            target.Key = source.ProviderUserKey.TryConvertTo<Guid>().Result;
            target.Name = source.UserName;
            target.Owner = new UserProfile { Name = "Admin", UserId = -1 };
            target.State = ContentSavedState.Draft;
            target.UpdateDate = source.LastActivityDate;
            target.Username = source.UserName;
}
Example #6
0
 // Umbraco.Code.MapAll -Trashed -Edited -Updater -Alias -VariesByCulture
 private void Map(IMember source, MemberBasic target, MapperContext context)
 {
     target.ContentTypeAlias = source.ContentType.Alias;
     target.CreateDate       = source.CreateDate;
     target.Email            = source.Email;
     target.Icon             = source.ContentType.Icon;
     target.Id         = int.MaxValue;
     target.Key        = source.Key;
     target.Name       = source.Name;
     target.Owner      = _commonMapper.GetOwner(source, context);
     target.ParentId   = source.ParentId;
     target.Path       = source.Path;
     target.Properties = context.MapEnumerable <Property, ContentPropertyBasic>(source.Properties);
     target.SortOrder  = source.SortOrder;
     target.State      = null;
     target.Udi        = Udi.Create(Constants.UdiEntityType.Member, source.Key);
     target.UpdateDate = source.UpdateDate;
     target.Username   = source.Username;
 }
        public void worker_initDataFromDatabase(bool newMakeCourseSchedule)
        {
            initWeekNo();

            //Judge ClassViewModel is initilized to get all teachers, all grades and all classes.
            if (!ClassViewModel.getInstance().mIsInitialized)
            {
                ClassViewModel.getInstance().worker_initData();
            }
            // load course groups and locations.
            justInitCourseGroupsAndLocations();

            //init selected grade id.
            MemberBasic currentUser = (MemberBasic)Application.Current.Properties["currentUser"];

            if (currentUser != null)
            {
                //set selectedGradeId;
                defaultTeacherId = currentUser.id;
                selectedClassId  = DatabaseHelper.getClassIdByTeacherId(defaultTeacherId);
            }
            if (selectedClassId == -1)
            {
                defaultTeacherId = ClassViewModel.getInstance().allTeachers[0].id;
                selectedClassId  = ClassViewModel.getInstance().allClasses[0].id;
            }

            defaultLocationId = ClassViewModel.getInstance().getClassDefaultLocationByClassId(selectedClassId);

            //1415211  14~15代表学年,2代表第二学期,11代表第十一周
            if (newMakeCourseSchedule)
            {
                oneWeekCourseWeekItems = new ObservableCollection <CourseWeekItem>();
            }
            else
            {
                oneWeekCourseWeekItems = DatabaseHelper.getOneWeekCourseWeekItems(selectedClassId, courseWeekNoForDB);
            }
            mHasSavedInMemoryHashTable = new Hashtable();
            mIsInitialized             = true;
        }
Example #8
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            TextBox     userTB       = (TextBox)FindName("operatorName");
            PasswordBox passowrdPB   = (PasswordBox)FindName("pwd");
            String      operatorName = userTB.Text;
            String      password     = passowrdPB.Password;
            MemberBasic currentUser  = DatabaseHelper.findOperatorUser(operatorName, password);

            if (currentUser != null)
            {
                Application.Current.Properties["currentUser"] = currentUser;
                navigateToMainWindow();
            }
            else
            {
                //retry login

                /*
                 * userTB.Text = "";
                 * userTB.Focus();*/// Not need clear the user name.
                passowrdPB.Password = null;
                passowrdPB.Focus();
            }
        }