private void SetScheduledByLabel(IHistory history) { Sage.Platform.Application.IContextService context = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Application.IContextService>(true); Sage.Platform.TimeZone tz = context["TimeZone"] as Sage.Platform.TimeZone; if (tz != null) { string startDate = tz.UTCDateTimeToLocalTime(history.StartDate).Date.ToShortDateString(); string createdate = tz.UTCDateTimeToLocalTime(history.CreateDate).Date.ToShortDateString(); if (history.Timeless) { startDate = history.StartDate.Date.ToShortDateString(); } string userName; IUser createUser = Sage.Platform.EntityFactory.GetById <IUser>(history.UserId); if (createUser != null) { userName = createUser.UserInfo.UserName; } else { if (history.CreateUser.ToUpper().Trim() == "PROCESS") { userName = "******"; } else { userName = "******"; } } CreateUser.Text = GetLocalResourceObject("rsScheduledOn") + " " + createdate + " " + GetLocalResourceObject("rsBy") + " " + userName + " " + GetLocalResourceObject("rsOriginallyFor") + " " + startDate; } }
protected void Page_Load(object sender, EventArgs e) { try { Sage.Platform.Application.IContextService context = Sage.Platform.Application.ApplicationContext.Current.Services.Get <IContextService>(true); Sage.Platform.TimeZone tz = (Sage.Platform.TimeZone)context.GetContext("TimeZone"); string uid = ApplicationContext.Current.Services.Get <IUserService>().UserId.Trim(); IUser u = EntityFactory.GetById <IUser>(uid); if (u == null) { log.ErrorFormat("TimeZone: Failed to get userid '{0}'", uid); } else { if (u.UserInfo.TimeZone != tz.KeyName) { u.UserInfo.TimeZone = tz.KeyName; u.Save(); } } } catch (Exception ex) { log.ErrorFormat(String.Format("TimeZone: Failed to set timezone: {0}", ex.Message)); } }