コード例 #1
0
        string FormatEduFormYears(IEnumerable <IEduProgramProfileFormYear> eppfys)
        {
            if (eppfys != null)
            {
                var sb = new StringBuilder();
                foreach (var eppfy in eppfys)
                {
                    var eduFormTitle = LocalizationHelper.GetStringWithFallback(
                        "TimeToLearn" + eppfy.EduForm.Title + ".Text",
                        Context.LocalResourceFile,
                        eppfy.EduForm.Title
                        ).ToLower();
                    sb.AppendFormat(
                        "<li>{0}</li>",
                        FormatHelper.JoinNotNullOrEmpty(
                            " &ndash; ",
                            eduFormTitle,
                            (eppfy.EduVolume != null)
                             ? UniversityFormatHelper.FormatTimeToLearn(eppfy.EduVolume.TimeToLearnMonths, eppfy.EduVolume.TimeToLearnHours, TimeToLearnDisplayMode.Both, "TimeToLearn", Context.LocalResourceFile)
                             : null
                            )
                        );
                }

                return(string.Format("<ul>{0}</ul>", sb));
            }

            return(string.Empty);
        }
コード例 #2
0
        /// <summary>
        /// Handles Init event for a control.
        /// </summary>
        /// <param name="e">Event args.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // parse QueryString
            var itemId = ParseHelper.ParseToNullable <int> (Request.QueryString ["division_id"]);

            // FIXME: Possible circular dependency as list can still contain childrens of current division
            parentDivisionSelector.DataSource = new DivisionQuery(ModelContext).ListExcept(itemId).OrderBy(d => d.Title);
            parentDivisionSelector.DataBind();

            // init working hours
            WorkingHoursLogic.Init(this, comboWorkingHours);

            // bind positions
            var positions = new FlatQuery <PositionInfo> (ModelContext).ListOrderBy(p => p.Title);

            comboHeadPosition.DataSource = positions.Select(p => new {
                p.PositionID,
                Title = UniversityFormatHelper.FormatTitleWithShortTitle(p.Title, p.ShortTitle)
            });

            comboHeadPosition.DataBind();
            comboHeadPosition.InsertDefaultItem(LocalizeString("NotSelected.Text"));
        }
コード例 #3
0
 string GetAcademicTitlesString()
 {
     return(FormatHelper.JoinNotNullOrEmpty("; ",
                                            AchievementViewModels
                                            .Where(ach => ach.AchievementType.GetSystemType() == SystemAchievementType.AcademicTitle)
                                            .Select(ach => UniversityFormatHelper.FormatShortTitle(ach.ShortTitle, ach.Title, ach.TitleSuffix))
                                            ));
 }
コード例 #4
0
        /// <summary>
        /// Handles Load event for a control
        /// </summary>
        /// <param name="e">Event args.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                var shouldBind = true;
                var now        = HttpContext.Current.Timestamp;

                var viewModel = GetViewModel();
                if (viewModel.IsEmpty())
                {
                    if (IsEditable)
                    {
                        this.Message("NothingToDisplay.Text", MessageType.Info, true);
                    }
                    shouldBind = false;
                }
                else if (!viewModel.EduProgram.IsPublished(now))
                {
                    if (IsEditable)
                    {
                        this.Message("NotPublished.Text", MessageType.Warning, true);
                    }
                    else
                    {
                        shouldBind = false;
                    }
                }

                if (shouldBind)
                {
                    // update module title
                    if (Settings.AutoTitle)
                    {
                        UniversityModuleHelper.UpdateModuleTitle(TabModuleId,
                                                                 UniversityFormatHelper.FormatEduProgramTitle(viewModel.EduProgram.Code, viewModel.EduProgram.Title)
                                                                 );
                    }

                    // bind the data
                    formEduProgram.DataSource = new List <EduProgramViewModel> {
                        viewModel.EduProgram
                    };
                    formEduProgram.DataBind();
                }
                else
                {
                    ContainerControl.Visible = IsEditable;
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #5
0
 string GetEduProgramLinks()
 {
     return(Wrap(FormatDocumentsLinkWithData(
                     GetDocuments(EduProgramProfile.GetDocumentsOfType(SystemDocumentType.EduProgram)),
                     UniversityFormatHelper.FormatEduProgramProfileTitle(EduProgram.Title, ProfileCode, ProfileTitle)
                     .Append(IsAdopted ? Context.LocalizeString("IsAdopted.Text") : null, " - "),
                     "oop",
                     IsAdopted ? "itemprop=\"adOpMain\"" : "itemprop=\"opMain\""
                     ), "eduName"));
 }
コード例 #6
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";
                }
            }
        }
コード例 #7
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());
            }
        }
コード例 #8
0
        public void OnInit(PortalModuleBase module, IEnumerable <PositionInfo> positions, IEnumerable <DivisionInfo> divisions)
        {
            Module = module;

            comboPositions.DataSource = positions.Select(p => new {
                p.PositionID,
                Title = UniversityFormatHelper.FormatTitleWithShortTitle(p.Title, p.ShortTitle)
            });
            comboPositions.DataBind();

            divisionSelector.DataSource = divisions;
            divisionSelector.DataBind();
        }
コード例 #9
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);
        }
コード例 #10
0
        /// <summary>
        /// Handles Load event for a control
        /// </summary>
        /// <param name="e">Event args.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                var employee = GetEmployee();
                var hasData  = employee != null;
                var now      = HttpContext.Current.Timestamp;

                if (!hasData)
                {
                    // employee wasn't set or not found
                    if (IsEditable)
                    {
                        this.Message("NothingToDisplay.Text", MessageType.Info, true);
                    }
                }
                else if (!employee.IsPublished(now))
                {
                    // employee isn't published
                    if (IsEditable)
                    {
                        this.Message("EmployeeNotPublished.Text", MessageType.Warning, true);
                    }
                }

                // display module only in edit mode and only if we have published data to display
                ContainerControl.Visible = IsEditable || (hasData && employee.IsPublished(now));

                // display module content only if it exists and published (or in edit mode)
                var displayContent = hasData && (IsEditable || employee.IsPublished(now));

                panelEmployee.Visible = displayContent;

                if (displayContent)
                {
                    if (Settings.AutoTitle)
                    {
                        UniversityModuleHelper.UpdateModuleTitle(TabModuleId,
                                                                 UniversityFormatHelper.AbbrName(employee.FirstName, employee.LastName, employee.OtherName)
                                                                 );
                    }

                    // display employee info
                    Display(employee);
                }
            }
            catch (Exception ex) {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #11
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();
        }
コード例 #12
0
        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);
        }
コード例 #13
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);
        }
コード例 #14
0
        string EvalAchievement(IEmployeeAchievement achievement, string objectName)
        {
            // TODO: Bind via viewmodel?
            if (objectName == "Type")
            {
                return(((achievement.Achievement != null)? achievement.Achievement.AchievementType : achievement.AchievementType)
                       .Localize(ResourceFileRoot));
            }
            if (objectName == NameOf(() => achievement.Title))
            {
                return((achievement.Achievement != null) ? achievement.Achievement.Title : achievement.Title);
            }

            if (objectName == "Years")
            {
                return(UniversityFormatHelper.FormatYears(
                           achievement.YearBegin,
                           achievement.YearEnd,
                           GetString("AtTheMoment.Text")));
            }
            if (objectName == NameOf(() => achievement.TitleSuffix))
            {
                return(achievement.TitleSuffix);
            }
            if (objectName == NameOf(() => achievement.IsTitle))
            {
                return(achievement.IsTitle ? GetString("Yes") : string.Empty);
            }
            if (objectName == NameOf(() => achievement.Description))
            {
                return(achievement.Description);
            }
            if (objectName == "DocumentUrl")
            {
                switch (Globals.GetURLType(achievement.DocumentURL))
                {
                case TabType.Tab: return(Globals.NavigateURL(int.Parse(achievement.DocumentURL)));

                case TabType.File: return(GetFullFileUrl(int.Parse(achievement.DocumentURL.ToUpperInvariant().Replace("FILEID=", ""))));

                default: return(achievement.DocumentURL);
                }
            }

            return(null);
        }
コード例 #15
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);
            }
        }
コード例 #16
0
        public static string FormatTitle(this IEduProgramProfile epp, bool withEduProgramCode = true)
        {
            if (withEduProgramCode)
            {
                return(UniversityFormatHelper.FormatEduProgramProfileTitle(
                           epp.EduProgram.Code,
                           epp.EduProgram.Title,
                           epp.ProfileCode,
                           epp.ProfileTitle
                           ));
            }

            return(UniversityFormatHelper.FormatEduProgramProfileTitle(
                       epp.EduProgram.Title,
                       epp.ProfileCode,
                       epp.ProfileTitle
                       ));
        }
コード例 #17
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();
        }
コード例 #18
0
        protected void gridEduProgramProfileObrnadzorDocuments_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var now = HttpContext.Current.Timestamp;

            // show / hide edit column
            e.Row.Cells [0].Visible = IsEditable;

            if (e.Row.RowType == DataControlRowType.Header)
            {
                // set right table section for header row
                e.Row.TableSection = TableRowSection.TableHeader;
            }
            else if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var eduProgramProfile = (EduProgramProfileDocumentsViewModel)e.Row.DataItem;

                e.Row.Attributes.Add("data-title", UniversityFormatHelper.FormatEduProgramProfileTitle(
                                         eduProgramProfile.EduProgram.Code, eduProgramProfile.EduProgram.Title,
                                         eduProgramProfile.ProfileCode, eduProgramProfile.ProfileTitle)
                                     .Append(eduProgramProfile.IsAdopted ? LocalizeString("IsAdopted.Text") : null, " - ")
                                     .Append(eduProgramProfile.EduLevel.Title, ": ")
                                     );

                if (IsEditable)
                {
                    // get edit link controls
                    var linkEdit = (HyperLink)e.Row.FindControl("linkEdit");
                    var iconEdit = (Image)e.Row.FindControl("iconEdit");

                    // fill edit link controls
                    linkEdit.NavigateUrl = EditUrl("eduprogramprofile_id",
                                                   eduProgramProfile.EduProgramProfileID.ToString(), "EditEduProgramProfileDocuments");
                    iconEdit.ImageUrl = UniversityIcons.Edit;
                }

                if (!eduProgramProfile.IsPublished(now))
                {
                    e.Row.AddCssClass("u8y-not-published");
                }
            }
        }
コード例 #19
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);
        }
コード例 #20
0
 // TODO: Move to the base library
 public static string ToDecimalString(this decimal value) =>
 UniversityFormatHelper.RemoveTrailingZeroes(value.ToString());
コード例 #21
0
        protected void BindEduPrograms(int eduLevelId)
        {
            comboEduProgram.DataSource = new EduProgramQuery(ModelContext).ListByEduLevel(eduLevelId)
                                         .Select(ep => new { Value = ep.EduProgramID, Text = UniversityFormatHelper.FormatEduProgramTitle(ep.Code, ep.Title) });

            comboEduProgram.DataBind();
            comboEduProgram.InsertDefaultItem(LocalizeString("NotSelected.Text"));
        }
コード例 #22
0
        void BindEduPrograms(int eduLevelId)
        {
            comboEduProgram.DataSource = new EduProgramCommonQuery(ModelContext).ListByEduLevel(eduLevelId)
                                         .Select(ep => new { Value = ep.EduProgramID, Text = UniversityFormatHelper.FormatEduProgramTitle(ep.Code, ep.Title) });

            comboEduProgram.DataBind();

            comboEduLevel.DataSource = ModelContext.Query <EduLevelInfo> ()
                                       .Where(el => el.ParentEduLevelId == eduLevelId || el.EduLevelID == eduLevelId)
                                       .OrderBy(el => el.ParentEduLevelId != null)
                                       .ToList();

            comboEduLevel.DataBind();
        }
コード例 #23
0
        void BindContacts(IEmployee employee)
        {
            var displayContacts = false;

            if (!string.IsNullOrWhiteSpace(employee.Phone))
            {
                labelPhone.Text = employee.Phone;
                displayContacts = true;
            }
            else
            {
                labelPhone.Visible = false;
            }

            if (!string.IsNullOrWhiteSpace(employee.CellPhone))
            {
                labelCellPhone.Text = employee.CellPhone;
                displayContacts     = true;
            }
            else
            {
                labelCellPhone.Visible = false;
            }

            if (!string.IsNullOrWhiteSpace(employee.Fax))
            {
                labelFax.Text   = string.Format(Localization.GetString("Fax.Format", LocalResourceFile), employee.Fax);
                displayContacts = true;
            }
            else
            {
                labelFax.Visible = false;
            }

            if (!string.IsNullOrWhiteSpace(employee.Messenger))
            {
                displayContacts     = true;
                labelMessenger.Text = employee.Messenger;
            }
            else
            {
                labelMessenger.Visible = false;
            }

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

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

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

            if (employee.UserID != null && !Null.IsNull(employee.UserID.Value))
            {
                linkUserProfile.NavigateUrl = Globals.UserProfileURL(employee.UserID.Value);
                displayContacts             = true;
            }
            else
            {
                linkUserProfile.Visible = false;
            }

            var workingPlaceAndHours = FormatHelper.JoinNotNullOrEmpty(", ", employee.WorkingPlace, employee.WorkingHours);

            if (!string.IsNullOrWhiteSpace(workingPlaceAndHours))
            {
                labelWorkingPlaceAndHours.Text = workingPlaceAndHours;
                displayContacts = true;
            }
            else
            {
                labelWorkingPlaceAndHours.Visible = false;
            }

            panelContacts.Visible = displayContacts;
        }
コード例 #24
0
        /// <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;
        }
コード例 #25
0
 string GetFileName(IEmployee employee, string extension)
 {
     return(UniversityFormatHelper.AbbrName(
                employee.FirstName, employee.LastName, employee.OtherName)
            .Replace(".", "").Replace(" ", "_") + extension);
 }
コード例 #26
0
        public override string Eval(string objectName, string collectionName, int index)
        {
            if (collectionName == nameof(Positions))
            {
                var position = Positions [index];
                if (objectName == "PositionTitle")
                {
                    return(position.FormatTitle());
                }
                if (objectName == "DivisionTitle")
                {
                    return(position.Division.Title);
                }
                if (objectName == NameOf(() => position.IsPrime))
                {
                    return(Positions [index].IsPrime ? GetString("Yes") : string.Empty);
                }
            }

            if (collectionName == nameof(Disciplines))
            {
                var discipline = Disciplines [index];
                var profile    = discipline.EduProgramProfile;
                if (objectName == NameOf(() => profile.EduProgram))
                {
                    return(UniversityFormatHelper.FormatEduProgramTitle(profile.EduProgram.Code, profile.EduProgram.Title));
                }
                if (objectName == NameOf(() => Disciplines [index].EduProgramProfile))
                {
                    return(UniversityFormatHelper.FormatEduProgramProfilePartialTitle(profile.ProfileCode, profile.ProfileTitle));
                }
                if (objectName == NameOf(() => profile.EduLevel))
                {
                    return(profile.EduLevel.Title);
                }
                if (objectName == NameOf(() => discipline.Disciplines))
                {
                    return(discipline.Disciplines);
                }
            }

            if (collectionName == nameof(Education))
            {
                var education = Education [index];
                return(EvalAchievement(education, objectName));
            }

            if (collectionName == nameof(Training))
            {
                var training = Training [index];
                return(EvalAchievement(training, objectName));
            }

            if (collectionName == nameof(Achievements))
            {
                var achievement = Achievements [index];
                return(EvalAchievement(achievement, objectName));
            }

            return(null);
        }
コード例 #27
0
 public static string FormatTitle(this IEduLevel eduLevel)
 {
     return(UniversityFormatHelper.FormatShortTitle(eduLevel.ShortTitle, eduLevel.Title));
 }
コード例 #28
0
 public static string FormatTitle(this IEduProgram ep)
 {
     return(UniversityFormatHelper.FormatEduProgramTitle(ep.Code, ep.Title));
 }
コード例 #29
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))
                                            ));
 }