Ejemplo n.º 1
0
 string GetAcademicTitlesString()
 {
     return(FormatHelper.JoinNotNullOrEmpty("; ",
                                            AchievementViewModels
                                            .Where(ach => ach.AchievementType.GetSystemType() == SystemAchievementType.AcademicTitle)
                                            .Select(ach => UniversityFormatHelper.FormatShortTitle(ach.ShortTitle, ach.Title, ach.TitleSuffix))
                                            ));
 }
Ejemplo n.º 2
0
        public static void ItemDataBound(PortalModuleBase module, object sender, RepeaterItemEventArgs e)
        {
            // exclude header & footer
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var gop = (GroupedOccupiedPosition)e.Item.DataItem;
                var op  = gop.OccupiedPosition;

                var labelPosition = (Label)e.Item.FindControl("labelPosition");
                var labelDivision = (Label)e.Item.FindControl("labelDivision");
                var linkDivision  = (HyperLink)e.Item.FindControl("linkDivision");

                labelPosition.Text = gop.Title;

                // don't display division title/link for single-entity divisions
                if (!op.Division.IsSingleEntity)
                {
                    var divisionShortTitle = UniversityFormatHelper.FormatShortTitle(
                        op.Division.ShortTitle,
                        op.Division.Title);

                    if (!string.IsNullOrWhiteSpace(op.Division.HomePage))
                    {
                        // link to division's homepage
                        labelDivision.Visible    = false;
                        linkDivision.NavigateUrl = UniversityUrlHelper.FormatCrossPortalTabUrl(
                            module,
                            int.Parse(op.Division.HomePage),
                            false);
                        linkDivision.Text = divisionShortTitle;
                    }
                    else
                    {
                        // only division title
                        linkDivision.Visible = false;
                        labelDivision.Text   = divisionShortTitle;
                    }

                    labelPosition.Text += ": "; // to prev label!
                }
                else
                {
                    labelDivision.Visible = false;
                    linkDivision.Visible  = false;
                }

                if (!op.Division.IsPublished(HttpContext.Current.Timestamp))
                {
                    labelPosition.CssClass = "u8y-not-published-element";
                    labelDivision.CssClass = "u8y-not-published-element";
                    linkDivision.CssClass  = "u8y-not-published-element";
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            comboMode.DataSource = Enum.GetNames(typeof(EmployeeDirectoryMode));
            comboMode.DataBind();

            // fill edulevels list
            foreach (var eduLevel in new EduLevelQuery(ModelContext).List())
            {
                listEduLevels.AddItem(UniversityFormatHelper.FormatShortTitle(eduLevel.ShortTitle, eduLevel.Title), eduLevel.EduLevelID.ToString());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Displays the specified employee.
        /// </summary>
        /// <param name="employee">Employee.</param>
        protected void Display(IEmployee employee)
        {
            // occupied positions
            var positions = employee.Positions
                            .OrderByDescending(op => op.Position.Weight)
                            .GroupByDivision(HttpContext.Current.Timestamp, IsEditable);

            // TODO: Grey out not published divisions
            if (positions.Any())
            {
                repeaterPositions.DataSource = positions;
                repeaterPositions.DataBind();
            }
            else
            {
                repeaterPositions.Visible = false;
            }

            // Full name
            var fullName = UniversityFormatHelper.FullName(employee.FirstName, employee.LastName, employee.OtherName);

            labelFullName.Text = fullName;

            EmployeePhotoLogic.Bind(employee, imagePhoto, Settings.PhotoWidth);

            var employeeDetailsUrl = UrlHelper.AdjustPopupUrl(
                UniversityUrlHelper.IESafeEditUrl(this, Request, "employee_id", employee.EmployeeID.ToString(), "EmployeeDetails"),
                responseRedirect: false
                );

            linkPhoto.NavigateUrl = employeeDetailsUrl;

            // Employee titles
            var titles = employee.Achievements
                         .Select(ach => new EmployeeAchievementViewModel(ach, new ViewModelContext(this)))
                         .Where(ach => ach.IsTitle)
                         .Select(ach => UniversityFormatHelper.FormatShortTitle(ach.ShortTitle, ach.Title, ach.TitleSuffix).FirstCharToLower());

            var strTitles = FormatHelper.JoinNotNullOrEmpty(", ", titles);

            if (!string.IsNullOrWhiteSpace(strTitles))
            {
                labelAcademicDegreeAndTitle.Text = "&nbsp;&ndash; " + strTitles;
            }
            else
            {
                labelAcademicDegreeAndTitle.Visible = false;
            }

            BindContacts(employee);
        }
Ejemplo n.º 5
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // fill edulevels list
            foreach (var eduLevel in new EduLevelQuery(ModelContext).ListForEduProgram())
            {
                listEduLevels.AddItem(UniversityFormatHelper.FormatShortTitle(eduLevel.ShortTitle, eduLevel.Title), eduLevel.EduLevelID.ToString());
            }

            // bind divisions
            divisionSelector.DataSource = new FlatQuery <DivisionInfo> (ModelContext).ListOrderBy(d => d.Title);
            divisionSelector.DataBind();
        }
        public override IEditModel <EmployeeDisciplineInfo> Create(EmployeeDisciplineInfo model, ViewModelContext context)
        {
            var viewModel = new EmployeeDisciplineEditModel();

            CopyCstor.Copy <IEmployeeDisciplineWritable> (model, viewModel);

            viewModel.Code             = model.EduProgramProfile.EduProgram.Code;
            viewModel.Title            = model.EduProgramProfile.EduProgram.Title;
            viewModel.ProfileCode      = model.EduProgramProfile.ProfileCode;
            viewModel.ProfileTitle     = model.EduProgramProfile.ProfileTitle;
            viewModel.ProfileStartDate = model.EduProgramProfile.StartDate;
            viewModel.ProfileEndDate   = model.EduProgramProfile.EndDate;
            viewModel.EduLevelString   = UniversityFormatHelper.FormatShortTitle(model.EduProgramProfile.EduLevel.ShortTitle, model.EduProgramProfile.EduLevel.Title);

            return(viewModel);
        }
Ejemplo n.º 7
0
        protected override void OnUpdateItem(EmployeeDisciplineEditModel item)
        {
            item.EduProgramProfileID = int.Parse(ddlEduProfile.SelectedValue);
            // if (item.EduProgramProfileID > 0) { }
            item.Disciplines = textDisciplines.Text.Trim();

            using (var modelContext = new UniversityModelContext()) {
                var eduProfile = new EduProgramProfileQuery(modelContext).SingleOrDefault(item.EduProgramProfileID);
                item.Code             = eduProfile.EduProgram.Code;
                item.Title            = eduProfile.EduProgram.Title;
                item.ProfileCode      = eduProfile.ProfileCode;
                item.ProfileTitle     = eduProfile.ProfileTitle;
                item.ProfileStartDate = eduProfile.StartDate;
                item.ProfileEndDate   = eduProfile.EndDate;
                item.EduLevelString   = UniversityFormatHelper.FormatShortTitle(eduProfile.EduLevel.ShortTitle, eduProfile.EduLevel.Title);
            }
        }
Ejemplo n.º 8
0
        public static string FormatDivisionLink(this OccupiedPositionInfo op, IModuleControl module)
        {
            // don't display division title/link for single-entity divisions
            if (!op.Division.IsSingleEntity)
            {
                var strDivision = UniversityFormatHelper.FormatShortTitle(op.Division.ShortTitle, op.Division.Title);
                if (!string.IsNullOrWhiteSpace(op.Division.HomePage))
                {
                    strDivision = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>",
                                                UniversityUrlHelper.FormatURL(module, op.Division.HomePage, false), strDivision);
                }

                return(strDivision);
            }

            return(string.Empty);
        }
Ejemplo n.º 9
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // fill edulevels list
            foreach (var eduLevel in new EduLevelQuery(ModelContext).ListForEduProgram())
            {
                listEduLevels.AddItem(UniversityFormatHelper.FormatShortTitle(eduLevel.ShortTitle, eduLevel.Title), eduLevel.EduLevelID.ToString());
            }

            // fill columns list
            foreach (var column in Enum.GetNames(typeof(EduProgramDirectoryColumn)))
            {
                listColumns.AddItem(LocalizeString("EduProgram" + column + ".Column"), column);
            }

            // bind divisions
            divisionSelector.DataSource = new FlatQuery <DivisionInfo> (ModelContext).ListOrderBy(d => d.Title);
            divisionSelector.DataBind();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Groups the occupied positions in same division
        /// </summary>
        /// <returns>The occupied positions grouped by division.</returns>
        /// <param name="occupiedPositions">The occupied positions to group by division.</param>
        public static IEnumerable <GroupedOccupiedPosition> GroupByDivision(this IEnumerable <OccupiedPositionInfo> occupiedPositions,
                                                                            DateTime now, bool isEditable)
        {
            var gops = occupiedPositions
                       .Where(op => op.Division.IsPublished(now) || isEditable)
                       .Select(op => new GroupedOccupiedPosition(op)).ToList();

            for (var i = 0; i < gops.Count; i++)
            {
                var gop  = gops [i];
                var gopp = gop.OccupiedPosition;

                // first combine position short title with it's suffix
                gop.Title = FormatHelper.JoinNotNullOrEmpty(" ",
                                                            UniversityFormatHelper.FormatShortTitle(gopp.Position.ShortTitle, gopp.Position.Title), gopp.TitleSuffix);

                for (var j = i + 1; j < gops.Count;)
                {
                    if (gopp.DivisionID == gops [j].OccupiedPosition.DivisionID)
                    {
                        gop.Title += ", " + FormatHelper.JoinNotNullOrEmpty(
                            " ",
                            UniversityFormatHelper.FormatShortTitle(
                                gops [j].OccupiedPosition.Position.ShortTitle,
                                gops [j].OccupiedPosition.Position.Title),
                            gops [j].OccupiedPosition.TitleSuffix);

                        // remove groupped item
                        gops.RemoveAt(j);
                        continue;
                    }
                    j++;
                }
            }

            return(gops);
        }
        /// <summary>
        /// Handles the items being bound to the datalist control. In this method we merge the data with the
        /// template defined for this control to produce the result to display to the user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void listEmployees_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
        {
            var now = HttpContext.Current.Timestamp;

            // e.Item.DataItem is of EmployeeListInfo class
            var employee = (IEmployee)e.Item.DataItem;

            // find controls in DataList item template
            var linkEdit     = (HyperLink)e.Item.FindControl("linkEdit");
            var imageEdit    = (Image)e.Item.FindControl("imageEdit");
            var imagePhoto   = (Image)e.Item.FindControl("imagePhoto");
            var linkDetails  = (HyperLink)e.Item.FindControl("linkDetails");
            var linkFullName = (HyperLink)e.Item.FindControl("linkFullName");
            var labelAcademicDegreeAndTitle = (Label)e.Item.FindControl("labelAcademicDegreeAndTitle");
            var labelPositions     = (Label)e.Item.FindControl("labelPositions");
            var labelPhones        = (Label)e.Item.FindControl("labelPhones");
            var linkEmail          = (HyperLink)e.Item.FindControl("linkEmail");
            var linkSecondaryEmail = (HyperLink)e.Item.FindControl("linkSecondaryEmail");
            var linkWebSite        = (HyperLink)e.Item.FindControl("linkWebSite");
            var linkUserProfile    = (HyperLink)e.Item.FindControl("linkUserProfile");

            // edit link
            if (IsEditable)
            {
                if (Null.IsNull(Settings.DivisionID))
                {
                    linkEdit.NavigateUrl = EditUrl("employee_id", employee.EmployeeID.ToString(), "EditEmployee");
                }
                else
                {
                    linkEdit.NavigateUrl = EditUrl("employee_id", employee.EmployeeID.ToString(),
                                                   "EditEmployee", "division_id", Settings.DivisionID.ToString());
                }
            }

            // make edit link visible in edit mode
            linkEdit.Visible  = IsEditable;
            imageEdit.Visible = IsEditable;

            // mark non-published employees, as they visible only to editors
            if (!employee.IsPublished(now))
            {
                if (e.Item.ItemType == ListItemType.Item)
                {
                    e.Item.CssClass = listEmployees.ItemStyle.CssClass + " _nonpublished";
                }
                else
                {
                    e.Item.CssClass = listEmployees.AlternatingItemStyle.CssClass + " _nonpublished";
                }
            }

            // fill the controls

            // employee photo
            EmployeePhotoLogic.Bind(employee, imagePhoto, Settings.PhotoWidth, true);

            var employeeDetailsUrl = UrlHelper.AdjustPopupUrl(
                UniversityUrlHelper.IESafeEditUrl(this, Request, "employee_id", employee.EmployeeID.ToString(), "EmployeeDetails"),
                responseRedirect: false
                );

            // photo fallback
            if (string.IsNullOrWhiteSpace(imagePhoto.ImageUrl))
            {
                linkDetails.Visible = false;
            }
            else
            {
                // link to employee details
                linkDetails.NavigateUrl = employeeDetailsUrl;
            }

            // employee fullname
            linkFullName.Text        = UniversityFormatHelper.FullName(employee.FirstName, employee.LastName, employee.OtherName);
            linkFullName.NavigateUrl = employeeDetailsUrl;

            // get current employee title achievements
            var achievements = employee.Achievements
                               .Select(ea => new EmployeeAchievementViewModel(ea, ViewModelContext))
                               .Where(ach => ach.IsTitle);

            var titles = achievements.Select(ach => UniversityFormatHelper.FormatShortTitle(ach.ShortTitle, ach.Title, ach.TitleSuffix).FirstCharToLower());

            // employee title achievements
            var strTitles = FormatHelper.JoinNotNullOrEmpty(", ", titles);

            if (!string.IsNullOrWhiteSpace(strTitles))
            {
                labelAcademicDegreeAndTitle.Text = "&nbsp;&ndash; " + strTitles;
            }
            else
            {
                labelAcademicDegreeAndTitle.Visible = false;
            }

            // phones
            var phones = FormatHelper.JoinNotNullOrEmpty(", ", employee.Phone, employee.CellPhone);

            if (!string.IsNullOrWhiteSpace(phones))
            {
                labelPhones.Text = phones;
            }
            else
            {
                labelPhones.Visible = false;
            }

            // email
            if (!string.IsNullOrWhiteSpace(employee.Email))
            {
                linkEmail.NavigateUrl = "mailto:" + employee.Email;
                linkEmail.Text        = employee.Email;
            }
            else
            {
                linkEmail.Visible = false;
            }

            // secondary email
            if (!string.IsNullOrWhiteSpace(employee.SecondaryEmail))
            {
                linkSecondaryEmail.NavigateUrl = "mailto:" + employee.SecondaryEmail;
                linkSecondaryEmail.Text        = employee.SecondaryEmail;
            }
            else
            {
                linkSecondaryEmail.Visible = false;
            }

            // webSite
            if (!string.IsNullOrWhiteSpace(employee.WebSite))
            {
                linkWebSite.NavigateUrl = UniversityFormatHelper.FormatWebSiteUrl(employee.WebSite);
                linkWebSite.Text        = UniversityFormatHelper.FormatWebSiteLabel(employee.WebSite, employee.WebSiteLabel);
            }
            else
            {
                linkWebSite.Visible = false;
            }

            // profile link
            if (employee.UserID != null && !Null.IsNull(employee.UserID.Value))
            {
                linkUserProfile.NavigateUrl = Globals.UserProfileURL(employee.UserID.Value);
                // TODO: Replace profile text with something more sane
                linkUserProfile.Text = Localization.GetString("VisitProfile.Text", LocalResourceFile);
            }
            else
            {
                linkUserProfile.Visible = false;
            }

            // get current employee occupied positions, grouped
            var gops = employee.Positions
                       .OrderByDescending(op => op.DivisionID == Settings.DivisionID)
                       .ThenByDescending(op => op.Position.Weight)
                       .GroupByDivision(HttpContext.Current.Timestamp, IsEditable);

            // build positions value
            var positionsVisible = false;

            if (!gops.IsNullOrEmpty())
            {
                var strOps = string.Empty;
                foreach (var gop in gops)
                {
                    var cssClass = !gop.OccupiedPosition.Division.IsPublished(HttpContext.Current.Timestamp)
                        ? " class=\"u8y-not-published-element\"" : string.Empty;
                    strOps = FormatHelper.JoinNotNullOrEmpty("; ", strOps,
                                                             $"<span{cssClass}>"
                                                             // gop.Title is a comma-separated list of grouped positions
                                                             + FormatHelper.JoinNotNullOrEmpty(": ", gop.Title,
                                                             // TODO: Move to the module display settings?
                                                             // don't display division title also for current division
                                                                                               (gop.OccupiedPosition.DivisionID != Settings.DivisionID) ? gop.OccupiedPosition.FormatDivisionLink(this) : string.Empty)
                                                             + "</span>");
                }

                labelPositions.Text = $"<label>{LocalizeString ("OccupiedPositions.Text")}</label> {strOps}";
                positionsVisible    = true;
            }
            labelPositions.Visible = positionsVisible;
        }
Ejemplo n.º 12
0
 public static string FormatTitle(this IEduLevel eduLevel)
 {
     return(UniversityFormatHelper.FormatShortTitle(eduLevel.ShortTitle, eduLevel.Title));
 }
Ejemplo n.º 13
0
 string GetTrainingString()
 {
     return(FormatHelper.JoinNotNullOrEmpty("; ",
                                            AchievementViewModels
                                            .Where(ach => ach.AchievementType.IsOneOf(SystemAchievementType.Training, SystemAchievementType.ProfRetraining))
                                            .Select(ach => FormatHelper.JoinNotNullOrEmpty("&nbsp;- ",
                                                                                           UniversityFormatHelper.FormatShortTitle(ach.ShortTitle, ach.Title, ach.TitleSuffix), ach.YearBegin))
                                            ));
 }