public override IList<SearchDocument> GetModifiedSearchDocuments (ModuleInfo modInfo, DateTime beginDate) { var searchDocs = new List<SearchDocument> (); var settings = new EmployeeListSettingsRepository ().GetSettings (modInfo); IEnumerable<EmployeeInfo> employees = null; using (var modelContext = new UniversityModelContext ()) { employees = new EmployeeQuery (modelContext).ListByDivisionId ( settings.DivisionID, settings.IncludeSubdivisions, settings.SortType); } var now = DateTime.Now; foreach (var employee in employees) { if (employee.LastModifiedOnDate.ToUniversalTime () > beginDate.ToUniversalTime ()) { var aboutEmployee = employee.SearchDocumentText; var sd = new SearchDocument () { PortalId = modInfo.PortalID, AuthorUserId = employee.LastModifiedByUserID, Title = employee.FullName, // Description = HtmlUtils.Shorten (aboutEmployee, 255, "..."), Body = aboutEmployee, ModifiedTimeUtc = employee.LastModifiedOnDate.ToUniversalTime (), UniqueKey = string.Format ("University_Employee_{0}", employee.EmployeeID), Url = string.Format ("/Default.aspx?tabid={0}#{1}", modInfo.TabID, modInfo.ModuleID), IsActive = employee.IsPublished (now) }; searchDocs.Add (sd); } } return searchDocs; }
public override IList<SearchDocument> GetModifiedSearchDocuments (ModuleInfo modInfo, DateTime beginDate) { var searchDocs = new List<SearchDocument> (); var settings = new DivisionSettingsRepository ().GetSettings (modInfo); using (var modelContext = new UniversityModelContext ()) { var division = modelContext.Get<DivisionInfo> (settings.DivisionID); if (division != null && division.LastModifiedOnDate.ToUniversalTime () > beginDate.ToUniversalTime ()) { var aboutDivision = division.SearchDocumentText; var sd = new SearchDocument () { PortalId = modInfo.PortalID, AuthorUserId = division.LastModifiedByUserID, Title = division.Title, // Description = HtmlUtils.Shorten (aboutDivision, 255, "..."), Body = aboutDivision, ModifiedTimeUtc = division.LastModifiedOnDate.ToUniversalTime (), UniqueKey = string.Format ("University_Division_{0}", division.DivisionID), Url = string.Format ("/Default.aspx?tabid={0}#{1}", modInfo.TabID, modInfo.ModuleID), IsActive = division.IsPublished (DateTime.Now) }; searchDocs.Add (sd); } return searchDocs; } }
public override DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search) { var eduProgramProfiles = new FindEduProgramProfileQuery (modelContext).List (search) .Select (epp => new EduProgramProfileViewModel (epp)); return DataTableConstructor.FromIEnumerable (eduProgramProfiles); }
public override DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search) { var dt = new DataTable (); DataRow dr; dt.Columns.Add (new DataColumn ("AchievementID", typeof (int))); dt.Columns.Add (new DataColumn ("Title", typeof (string))); dt.Columns.Add (new DataColumn ("ShortTitle", typeof (string))); dt.Columns.Add (new DataColumn ("AchievementType", typeof (string))); foreach (DataColumn column in dt.Columns) column.AllowDBNull = true; // REVIEW: Cannot set comparison options var achievements = (search == null) ? new FlatQuery<AchievementInfo> (modelContext).List () : new FlatQuery<AchievementInfo> (modelContext) .ListWhere (a => a.Title.Contains (search) || a.ShortTitle.Contains (search)); foreach (var achievement in achievements) { var col = 0; dr = dt.NewRow (); dr [col++] = achievement.AchievementID; dr [col++] = achievement.Title; dr [col++] = achievement.ShortTitle; dr [col++] = Localization.GetString ( AchievementTypeInfo.GetResourceKey (achievement.AchievementType), module.LocalResourceFile); dt.Rows.Add (dr); } return dt; }
public override IList<SearchDocument> GetModifiedSearchDocuments (ModuleInfo modInfo, DateTime beginDate) { var searchDocs = new List<SearchDocument> (); var settings = new EmployeeSettingsRepository ().GetSettings (modInfo); var employee = default (EmployeeInfo); using (var modelContext = new UniversityModelContext ()) { employee = modelContext.Get<EmployeeInfo> (settings.EmployeeID); } if (employee != null && employee.LastModifiedOnDate.ToUniversalTime () > beginDate.ToUniversalTime ()) { var aboutEmployee = employee.SearchDocumentText; var sd = new SearchDocument () { PortalId = modInfo.PortalID, AuthorUserId = employee.LastModifiedByUserID, Title = employee.FullName, // Description = HtmlUtils.Shorten (aboutEmployee, 255, "..."), Body = aboutEmployee, ModifiedTimeUtc = employee.LastModifiedOnDate.ToUniversalTime (), UniqueKey = string.Format ("University_Employee_{0}", employee.EmployeeID), Url = string.Format ("/Default.aspx?tabid={0}#{1}", modInfo.TabID, modInfo.ModuleID), IsActive = employee.IsPublished (DateTime.Now) }; searchDocs.Add (sd); } return searchDocs; }
public override DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search) { // REVIEW: Cannot set comparison options var documents = (search == null) ? new FlatQuery<DocumentInfo> (modelContext).List () : new FlatQuery<DocumentInfo> (modelContext) .ListWhere (p => p.Title.Contains (search) || p.Url.Contains (search)); return DataTableConstructor.FromIEnumerable (documents); }
public override DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search) { // REVIEW: Cannot set comparison options var eduPrograms = (search == null) ? new FlatQuery<EduProgramInfo> (modelContext).List () : new FlatQuery<EduProgramInfo> (modelContext) .ListWhere (ep => ep.Code.Contains (search) || ep.Title.Contains (search)); return DataTableConstructor.FromIEnumerable (eduPrograms); }
/// <summary> /// Handles Load event for a control /// </summary> /// <param name="e">Event args.</param> protected override void OnLoad (EventArgs e) { base.OnLoad (e); try { if (!IsPostBack) { var division_id = Request.QueryString ["division_id"]; if (!string.IsNullOrWhiteSpace (division_id)) { var division = default (DivisionInfo); using (var modelContext = new UniversityModelContext ()) { division = modelContext.Get<DivisionInfo> (int.Parse (division_id)); } if (division != null) { var vcard = division.VCard; Response.Clear (); Response.ContentType = "text/x-vcard"; Response.AddHeader ("content-disposition", string.Format ("attachment; filename=\"{0}.vcf\"", division.FileName)); if (Request.Browser.Platform.ToUpperInvariant ().StartsWith ("WIN")) { // HACK: Windows russian version hack // TODO: Need a way to determine language / locale for division description Response.ContentEncoding = Encoding.GetEncoding (1251); vcard.Encoding = Response.ContentEncoding; } else { Response.ContentEncoding = Encoding.UTF8; } Response.Write (vcard.ToString ()); Response.Flush (); Response.Close (); } else { throw new Exception ("No division found with DivisionID=" + division_id); } } else { throw new Exception ("\"division_id\" query parameter should not be empty"); } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException (this, ex); } }
public override DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search) { // REVIEW: Cannot set comparison options var employees = (search == null) ? new FlatQuery<EmployeeInfo> (modelContext).List () : new FlatQuery<EmployeeInfo> (modelContext) .ListWhere (e => e.LastName.Contains (search) || e.FirstName.Contains (search) || e.OtherName.Contains (search) || e.CellPhone.Contains (search) || e.Phone.Contains (search) || e.Fax.Contains (search) || e.Email.Contains (search) || e.SecondaryEmail.Contains (search) || e.WebSite.Contains (search) || e.WebSiteLabel.Contains (search) || e.WorkingHours.Contains (search) ); return DataTableConstructor.FromIEnumerable (employees.Select (e => new EmployeeViewModel (e))); }
public abstract DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search);
public virtual void DataBind (PortalModuleBase module, UniversityModelContext modelContext, string search = null) { Grid.DataSource = GetDataTable (module, modelContext, search); module.Session [Grid.ID] = Grid.DataSource; Grid.DataBind (); }
/// <summary> /// Handles Click event for Update button /// </summary> /// <param name='sender'> /// Sender. /// </param> /// <param name='e'> /// Event args. /// </param> protected void buttonUpdate_Click (object sender, EventArgs e) { // HACK: Dispose current model context used in load to create new one for update if (modelContext != null) { modelContext.Dispose (); modelContext = null; } try { EduProgramInfo item; var isNew = false; // determine if we are adding or updating // ALT: if (Null.IsNull (itemId)) if (!itemId.HasValue) { // add new record item = new EduProgramInfo (); isNew = true; } else { // update existing record item = ModelContext.Get<EduProgramInfo> (itemId.Value); } // fill the object item.Code = textCode.Text.Trim (); item.Title = textTitle.Text.Trim (); item.Generation = textGeneration.Text.Trim (); item.StartDate = datetimeStartDate.SelectedDate; item.EndDate = datetimeEndDate.SelectedDate; item.HomePage = urlHomePage.Url; // update references item.EduLevelID = int.Parse (comboEduLevel.SelectedValue); item.EduLevel = ModelContext.Get<EduLevelInfo> (item.EduLevelID); item.DivisionId = divisionSelector.DivisionId; if (itemId == null) { item.CreatedOnDate = DateTime.Now; item.LastModifiedOnDate = item.CreatedOnDate; item.CreatedByUserID = UserInfo.UserID; item.LastModifiedByUserID = item.CreatedByUserID; ModelContext.Add<EduProgramInfo> (item); ModelContext.SaveChanges (false); if (checkAddDefaultProfile.Checked) { var defaultProfile = new EduProgramProfileInfo { ProfileCode = string.Empty, ProfileTitle = string.Empty, EduProgramID = item.EduProgramID, EduLevelId = item.EduLevelID, CreatedOnDate = item.CreatedOnDate, LastModifiedOnDate = item.LastModifiedOnDate, CreatedByUserID = item.CreatedByUserID, LastModifiedByUserID = item.LastModifiedByUserID, // unpublish profile EndDate = item.CreatedOnDate.Date }; ModelContext.Add<EduProgramProfileInfo> (defaultProfile); ModelContext.SaveChanges (false); } } else { item.LastModifiedOnDate = DateTime.Now; item.LastModifiedByUserID = UserInfo.UserID; // REVIEW: Solve on SqlDataProvider level on upgrage to 2.0.0? if (item.CreatedOnDate == default (DateTime)) { item.CreatedOnDate = item.LastModifiedOnDate; item.CreatedByUserID = item.LastModifiedByUserID; } ModelContext.Update<EduProgramInfo> (item); } // update EduProgram module settings then adding new item if (isNew && ModuleConfiguration.ModuleDefinition.DefinitionName == "R7.University.EduProgram") { var settingsRepository = new EduProgramSettingsRepository (); var settings = settingsRepository.GetSettings (ModuleConfiguration); settings.EduProgramId = item.EduProgramID; settingsRepository.SaveSettings (ModuleConfiguration, settings); } // update related documents new UpdateDocumentsCommand (ModelContext) .UpdateDocuments (formEditDocuments.GetData (), DocumentModel.EduProgram, item.EduProgramID); ModelContext.SaveChanges (); ModuleController.SynchronizeModule (ModuleId); Response.Redirect (Globals.NavigateURL (), true); } catch (Exception ex) { Exceptions.ProcessModuleLoadException (this, ex); } }
public override DataTable GetDataTable (PortalModuleBase module, UniversityModelContext modelContext, string search) { var divisions = new FindDivisionQuery (modelContext).List (search); return DataTableConstructor.FromIEnumerable (divisions); }