public RankChartGenerator(Database db, RankChartParameters rcp, string title) { _db = db; _rcp = rcp; _title = title; //Look up the time zone of the user _timeZone = TimeZones.GetTimeZone(_rcp.TimezoneOffsetIndex); //Determine the time range if (rcp.DateRangeType == DateRangeSelector.DateRanges.Custom) { _start = _rcp.StartTime; _end = _rcp.EndTime; } else { DateRangeSelector.GetDateRangeByType(rcp.DateRangeType, out _start, out _end); } //Add 1 day to the end of the range, so that it ecompasses the whole last day in the range _end = _end.AddDays(1); _chart = new XYChart(ChartWidth, ChartHeight, 0xeeeeee, 0x000000, 1); Chart.setLicenseCode(CHARTDIRECTOR_LICENSE); }
public void GetTimeZone_InvalidZone_Failure() { var timeZones = new TimeZones(_connectionServer); ConnectionTimeZone oTemp; WebCallResult res = timeZones.GetTimeZone(-1, out oTemp); Assert.IsFalse(res.Success, "Fetching time zone of -1 should fail."); }
public void GetTimeZone_Success() { var timeZones = new TimeZones(_connectionServer); ConnectionTimeZone oTemp; WebCallResult res = timeZones.GetTimeZone(227, out oTemp); Assert.IsTrue(res.Success, "Failed to fetch 227 time zone:" + res.ToString()); Console.WriteLine(oTemp.ToString()); }
private static void SetDefaultTimeZone(DCPLIdentity identity) { if (identity.TimeZone == null && HttpContext.Current != null) { HttpCookie timeZoneCookie = HttpContext.Current.Request.Cookies["TimeZone"]; if (timeZoneCookie != null) { identity.TimeZone = TimeZones.GetTimeZone(timeZoneCookie.Value); } if (identity.TimeZone == null) { identity.TimeZone = TimeZoneInfo.Local; } } }
protected void Page_Load(object sender, EventArgs e) { if (_textMessage == null) { TextMessagePanel.Visible = false; } else { Win32TimeZone timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex); TextMessagePanel.Visible = true; TextMessageTimestamp.Text = timeZone.ToLocalTime(_textMessage.Timestamp).ToString(); TextMessage.Text = _textMessage.Message; Acknowledge.CommandArgument = _textMessage.Id.ToString(); } }
private void loadEngineStatus() { Database db = Global.GetDbConnection(); Service dbSvc = db.GetService(ServiceId); DateTime serverTime = db.GetServerTime(); Win32TimeZone timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex); bool suspectedCrash = dbSvc.Enabled && (Math.Abs(dbSvc.LastRunTime.Subtract(serverTime).TotalMinutes) > dbSvc.RunIntervalMinutes * 2 || // More than 2 cycles times have passed since last run time Math.Abs(dbSvc.LastHeartbeat.Subtract(serverTime).TotalMinutes) > EngineBase.HEARTBEAT_INTERVAL.TotalMinutes * 2); // More than 2 heartbeat cycle times have passed since last heartbeat Interval.Text = dbSvc.RunIntervalMinutes.ToString(); LastRunTime.Text = dbSvc.LastRunTime == new DateTime() ? "Never" : timeZone.ToLocalTime(dbSvc.LastRunTime).ToString(); LastHeartbeat.Text = dbSvc.LastHeartbeat == new DateTime() ? "Never" : timeZone.ToLocalTime(dbSvc.LastHeartbeat).ToString(); ServerTime.Text = timeZone.ToLocalTime(serverTime).ToString(); NextRunTime.Text = dbSvc.Enabled ? "~" + timeZone.ToLocalTime(dbSvc.LastRunTime.AddMinutes(dbSvc.RunIntervalMinutes)) : "Next time service is started"; EngineStatus.Text = string.Format("{0}{1}{2}{3}", suspectedCrash ? "<span style=\"font-weight:bold;\">Suspected crash (either 2 heartbeat or run times have past since last)</span><br />" : string.Empty, dbSvc.ForceRun ? "Forced run pending<br />" : string.Empty, dbSvc.ReloadConfiguration ? "Reload configuration pending<br />" : string.Empty, dbSvc.ReloadConfiguration ? (dbSvc.Enabled ? "Will be started next heartbeat" : "Will be stopped next hearteat") : (dbSvc.Enabled ? "Enabled" : "Disabled")); StartEngine.Visible = !dbSvc.Enabled; StopEngine.Visible = dbSvc.Enabled; ServiceInformation.Style.Add("color", suspectedCrash ? "red" : dbSvc.Enabled && !dbSvc.ReloadConfiguration ? "green" : "#E0691A"); }
private void displaySubscription(EventRssSubscription ers) { Win32TimeZone timeZone; timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex); if (ers == null) { txtName.Enabled = false; txtName.Text = ""; cmdReadFeedTitle.Enabled = false; txtDescription.Enabled = false; txtDescription.Text = ""; txtRssUrl.Enabled = false; txtRssUrl.Text = ""; categoryList.Enabled = false; categoryList.SelectAnyItem(); lblLastCheck.Text = ""; } else { txtName.Enabled = true; txtName.Text = ers.Name; cmdReadFeedTitle.Enabled = true; txtDescription.Enabled = true; txtDescription.Text = ers.Description; txtRssUrl.Enabled = true; txtRssUrl.Text = ers.RssUrl; categoryList.Enabled = true; categoryList.SetSelectedCategory(ers.EventCategory); if (ers.LastCheck == null) { lblLastCheck.Text = "Never"; } else { lblLastCheck.Text = timeZone.ToLocalTime((DateTime)ers.LastCheck).ToString(); } } }
private void loadEngineStatus() { int?serviceId = ServiceIdParameter; if (serviceId != null) { RtEngineBase engine = RtEngines.GetRtEngine((int)serviceId); Database db = Global.GetDbConnection(); Service dbSvc = db.GetService(engine.ServiceId); DateTime serverTime = db.GetServerTime(); Win32TimeZone timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex); ServiceOwnerName.Text = engine.ServiceOwnerName; HeartBeating.Text = engine.IsHeartBeating ? string.Empty : "Not"; IsRunning.Text = engine.IsRunning ? "Running" : "Stopped"; IsServiceOwner.Text = engine.IsServiceOwner ? "Yes" : "No"; WebServiceInformation.Style.Add("color", engine.IsServiceOwner && engine.IsRunning || !engine.IsServiceOwner && !engine.IsRunning ? "green" : "red"); bool suspectedCrash = dbSvc.Enabled && (Math.Abs(dbSvc.LastRunTime.Subtract(serverTime).TotalMinutes) > dbSvc.RunIntervalMinutes * 2 || // More than 2 cycles times have passed since last run time Math.Abs(dbSvc.LastHeartbeat.Subtract(serverTime).TotalMinutes) > EngineBase.HEARTBEAT_INTERVAL.TotalMinutes * 2); // More than 2 heartbeat cycle times have passed since last heartbeat ServiceOwner.Text = dbSvc.Owner; LastRunTime.Text = dbSvc.LastRunTime == new DateTime() ? "Never" : timeZone.ToLocalTime(dbSvc.LastRunTime).ToString(); LastHeartbeat.Text = dbSvc.LastHeartbeat == new DateTime() ? "Never" : timeZone.ToLocalTime(dbSvc.LastHeartbeat).ToString(); ServerTime.Text = timeZone.ToLocalTime(serverTime).ToString(); NextRunTime.Text = dbSvc.Enabled ? "~" + timeZone.ToLocalTime(dbSvc.LastRunTime.AddMinutes(dbSvc.RunIntervalMinutes)) : "Next time service is started"; EngineDatabaseStatus.Text = string.Format("{0}{1}{2}{3}", suspectedCrash ? "<span style=\"font-weight:bold;\">Suspected crash</span><br />" : string.Empty, dbSvc.ForceRun ? "Forced run pending<br />" : string.Empty, dbSvc.ReloadConfiguration ? "Reload configuration pending<br />" : string.Empty, dbSvc.ReloadConfiguration ? (dbSvc.Enabled ? "Will be started next heartbeat" : "Will be stopped next hearteat") : (dbSvc.Enabled ? "Enabled" : "Disabled")); ServiceInformation.Style.Add("color", suspectedCrash ? "red" : dbSvc.Enabled && !dbSvc.ReloadConfiguration ? "green" : "#E0691A"); StartHeartbeat.Visible = !engine.IsHeartBeating; StopHeartbeat.Visible = engine.IsHeartBeating; StartEngine.Visible = !engine.IsRunning; StopEngine.Visible = engine.IsRunning; } else { AjaxPanel1.Visible = false; } }
public static UserConfig LoadPersonalData(string userName, string passWord, int customerId) { string strSQL; strSQL = "SELECT USERACCOUNT, PASSWORD, GROUPID, UID, MANAGERID, CONVERT(VARCHAR(5),WORKSTART_1,114) AS STARTWORKHOUR, CONVERT(VARCHAR(5),WORKEND_2,114) AS ENDWORKHOUR, OFFICEID, (ACCOUNT.NAME+' '+ACCOUNT.SURNAME) AS USERNAME, DIARYACCOUNT, OFFICEACCOUNT, DATEPART(HH,WORKSTART_1) AS STARTHOUR, DATEPART(HH,WORKEND_1) AS ENDHOUR, TIMEZONES.MTIMEZONE, TIMEZONES.HTIMEZONE, TIMEZONES.DAYLIGHTSAVINGSTART, TIMEZONES.DAYLIGHTSAVINGEND, TIMEZONES.MDAYLIGHT, DATEPART(HH,WORKSTART_2) AS STARTHOUR2, DATEPART(HH,WORKEND_2) AS ENDHOUR2, WORKDAYS, PERSISTLOGIN, TIMEZONES.DTZ, TIMEZONES.DAYLIGHTSAVINGSTART, TIMEZONES.DAYLIGHTSAVINGEND, PAGING, FULLSCREEN, VIEWBIRTHDATE, CULTURE, ACCOUNT.ACTIVE, ACCOUNT.SESSIONTIMEOUT, ACCOUNT.INSERTGROUPS, ACCOUNT.FIRSTDAYOFWEEK, ACCOUNT.OTHERGROUPS, TUSTENA_DATA.EMAIL AS CUSTOMEREMAIL, TUSTENA_DATA.DEBUGMODE, ACCOUNT.ZONES, ACCOUNT.ACCESSLEVEL FROM ACCOUNT LEFT OUTER JOIN TIMEZONES ON ACCOUNT.TIMEZONE = TIMEZONES.SHORTNAME CROSS JOIN TUSTENA_DATA "; if (customerId > -1) { strSQL += " WHERE (USERACCOUNT=@USERNAME AND PASSWORD=@PASSWORD AND TUSTENA_DATA.ACTIVE=1) "; } else { strSQL += " WHERE (USERACCOUNT=@USERNAME AND PASSWORD=@PASSWORD AND TUSTENA_DATA.ACTIVE=1) "; } DbSqlParameterCollection param = new DbSqlParameterCollection(); param.Add(new DbSqlParameter("@USERNAME", userName)); param.Add(new DbSqlParameter("@PASSWORD", passWord)); DataSet ds = DatabaseConnection.SecureCreateDataset(strSQL, param); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; bool activeCompany = true; bool inTest = false; bool activeAccount = Convert.ToBoolean(dr["active"]); DataRow acBool; acBool = DatabaseConnection.CreateDataset("SELECT * FROM TUSTENA_DATA").Tables[0].Rows[0]; activeCompany = true; string cc = Thread.CurrentThread.CurrentCulture.DisplayName; if (activeCompany && activeAccount) { UserConfig UC = new UserConfig(); UC.UserName = dr["UserAccount"].ToString(); UC.UserGroupId = Convert.ToInt32(dr["GroupID"]); UC.Logged = LoggedStatus.yes; UC.UserId = Convert.ToInt32(dr["UID"]); UC.MyBossId = Convert.ToInt32(dr["ManagerID"]); UC.WorkStartHour = (string)dr["StartWorkHour"]; UC.WorkEndHour = (string)dr["EndWorkHour"]; UC.Office = (int)dr["OfficeID"]; UC.UserRealName = (string)dr["UserName"]; UC.UserAgenda = (string)dr["DiaryAccount"]; UC.OfficeAgenda = (string)dr["OfficeAccount"]; UC.StartHourAM = (int)dr["StartHour"]; UC.EndHourAM = (int)dr["EndHour"]; UC.StartHourPM = (int)dr["starthour2"]; UC.EndHourPM = (int)dr["endhour2"]; UC.WeekWorkDays = (Byte)dr["WorkDays"]; UC.PagingSize = int.Parse(dr["Paging"].ToString()); UC.FullScreen = (bool)dr["FullScreen"]; UC.ViewBirthDate = (bool)dr["ViewBirthDate"]; UC.ImpersonateUser = 0; UC.ImpersonateOffice = 0; UC.DebugMode = (bool)dr["debugmode"]; UC.InsertGroups = (dr["InsertGroups"] == DBNull.Value) ? "" : (string)dr["InsertGroups"]; UC.AccessLevel = (int)dr["accesslevel"]; UC.FirstDayOfWeek = (bool)dr["FirstDayOfWeek"]; UC.MailingAddress = (string)dr["CustomerEmail"]; if ((dr["DayLightSavingStart"].ToString() != null && dr["DayLightSavingStart"].ToString().Length != 0)) { if (DateTime.Now >= (DateTime)dr["DayLightSavingStart"] && DateTime.Now <= (DateTime)dr["DayLightSavingEnd"]) { UC.HTimeZone = (double)dr["HTimeZone"] + (double)dr["DTZ"]; } else { UC.HTimeZone = (double)dr["HTimeZone"]; } } else { UC.HTimeZone = (double)dr["HTimeZone"]; } if (HttpContext.Current.Request.Cookies["CulturePref"] == null) { UC.Culture = dr["Culture"].ToString(); } else if (HttpContext.Current.Request.Cookies["CulturePref"].ToString().Length > 1) { UC.Culture = HttpContext.Current.Request.Cookies["CulturePref"].Value.ToString(); } else { UC.Culture = CultureInfo.CurrentUICulture.Name; } UC.CultureSpecific = UC.Culture.Substring(UC.Culture.Length - 2).ToLower(); UC.PersistLogin = (bool)dr["PersistLogin"]; if (HttpContext.Current.Session != null) { HttpContext.Current.Session.Timeout = (int)dr["SessionTimeout"]; } StringBuilder othergroups = new StringBuilder(); othergroups.AppendFormat("id={0} OR DEPENDENCY LIKE '%|{0}|%' OR ", dr[2].ToString()); string[] OG = dr["OtherGroups"].ToString().Split('|'); if (OG.Length > 0) { foreach (string ogid in OG) { if (ogid.Length > 0) { othergroups.AppendFormat("ID={0} OR DEPENDENCY LIKE '%|{0}|%' OR ", ogid); } } } othergroups.Remove(othergroups.Length - 3, 3); string sqlString = "SELECT ID,DEPENDENCY FROM GROUPS WHERE " + othergroups.ToString(); DataSet dsGroup = DatabaseConnection.CreateDataset(sqlString); string dependency = "|"; if (dsGroup.Tables[0].Rows.Count > 0) { foreach (DataRow drdip in dsGroup.Tables[0].Rows) { dependency += drdip["id"].ToString() + "|"; } } if (dependency.Length > 1) { UC.GroupDependency = dependency; } else { UC.GroupDependency = "0"; } DataSet DSAdmGrID; DSAdmGrID = DatabaseConnection.CreateDataset("SELECT ADMINGROUPID FROM TUSTENA_DATA"); UC.AdminGroupId = (long)DSAdmGrID.Tables[0].Rows[0][0]; UC.LTZ = TimeZones.GetTimeZone(Convert.ToInt32(DatabaseConnection.SqlScalar("SELECT TIMEZONEINDEX FROM ACCOUNT WHERE UID=" + UC.UserId))); UC.myDTFI = new CultureInfo(UC.Culture).DateTimeFormat; UC.Zones = (Convert.ToInt32(dr["accesslevel"].ToString()) > 0 && dr["zones"].ToString().Length > 0)?dr["zones"].ToString():string.Empty; UC.Modules = (ActiveModules)acBool["MODULES"]; return(UC); } else { UserConfig UC = new UserConfig(); if (inTest) { UC.Logged = LoggedStatus.testing; } else { UC.Logged = LoggedStatus.no; } return(UC); } } else { UserConfig UC = new UserConfig(); UC.Logged = LoggedStatus.no; return(UC); } }