protected void Page_Load(object sender, EventArgs e) { try { Common.prepareDatabase(); if (Session["_winkToken"] == null) { Response.Redirect("~/login.aspx", false); } else { string startpage = SettingMgmt.getSetting("StartPage"); if (string.IsNullOrWhiteSpace(startpage)) { startpage = "Control.aspx"; } Response.Redirect("~/" + startpage, false); } } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Default.Page_Load", ex.Message, EventLogEntryType.Error); } }
protected void rblenabled_SelectedIndexChanged(object sender, EventArgs e) { try { tmrRefresh.Enabled = Convert.ToBoolean(rblenabled.SelectedValue); SettingMgmt.saveSetting("RefreshEnabled-" + Request.RawUrl.Replace("/", "").Replace(".aspx", ""), rblenabled.SelectedValue); } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Master.rblenabled_SelectedIndexChanged", ex.Message, EventLogEntryType.Error); } }
protected void tbTimer_TextChanged(object sender, EventArgs e) { try { tmrRefresh.Interval = Convert.ToInt32(tbTimer.Text) * 60000; SettingMgmt.saveSetting("RefreshTimer-" + Request.RawUrl.Replace("/", "").Replace(".aspx", ""), tbTimer.Text); } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Master.tbTimer_TextChanged", ex.Message, EventLogEntryType.Error); } }
protected void Page_Load(object sender, EventArgs e) { string strShowPubNub = SettingMgmt.getSetting("Show-Pubnub-Log-In-Monitor"); if (strShowPubNub.ToLower() == "true" && PubNub.myPubNub.hasPubNub) { rowPubNub.Visible = true; } else { rowPubNub.Visible = false; } }
protected void btnSaveEdit_Click(object sender, EventArgs e) { try { string strSettings = tbEdit.Text.Replace("\n", "").Replace("\r", ""); SettingMgmt.saveManualEdit(strSettings); BindData(); } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Settings.btnSaveEdit_Click", ex.Message, EventLogEntryType.Error); } }
public static DateTime getLocalTime() { Int32 timezone = 0; string strtimezone = SettingMgmt.getSetting("TimeZone-Adjuster"); Int32.TryParse(strtimezone, out timezone); DateTime dtnow = DateTime.Now.ToUniversalTime().AddHours(timezone); if (DateTime.Now.IsDaylightSavingTime()) { dtnow = dtnow.AddHours(1); } return(dtnow); }
protected void ibExpand_Click(object sender, EventArgs e) { try { string cmdArg = string.Empty; if (sender is ImageButton) { ImageButton btn = (ImageButton)sender; cmdArg = btn.CommandArgument; } else if (sender is Button) { Button btn = (Button)sender; cmdArg = btn.CommandArgument; } else if (sender is LinkButton) { LinkButton btn = (LinkButton)sender; cmdArg = btn.CommandArgument; } if (cmdArg == "hide") { tblCollapsed.Visible = true; tblExpand.Visible = false; SettingMgmt.saveSetting("Menu-Default-State", "hide"); } else { tblCollapsed.Visible = false; tblExpand.Visible = true; SettingMgmt.saveSetting("Menu-Default-State", "show"); } cellMenu.BackColor = tblExpand.Visible ? System.Drawing.ColorTranslator.FromHtml("#eeeeee") : System.Drawing.ColorTranslator.FromHtml("#22b9ec"); Response.Redirect(Request.RawUrl); } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Master.ibExpand_Click", ex.Message, EventLogEntryType.Error); } }
protected void btnWipe_Click(object sender, EventArgs e) { try { SettingMgmt.wipeSettings(); if (Request.Cookies["login"] != null) { HttpCookie aCookie = new HttpCookie("login"); aCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(aCookie); } Session.Abandon(); Response.Redirect("~/Login.aspx"); } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Settings.btnWipe_Click", ex.Message, EventLogEntryType.Error); } }
protected void btnSave_Click(object sender, EventArgs e) { try { foreach (DataListItem item in dlRequiredSettings.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { Label lbl = (Label)item.FindControl("lblKey"); TextBox tb = (TextBox)item.FindControl("tbValue"); HiddenField hf = (HiddenField)item.FindControl("hfValue"); if (tb.Text != hf.Value) { SettingMgmt.saveSetting(lbl.Text, tb.Text); } } } foreach (DataListItem item in dlAdditionalSettings.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { Label lbl = (Label)item.FindControl("lblKey"); TextBox tb = (TextBox)item.FindControl("tbValue"); HiddenField hf = (HiddenField)item.FindControl("hfValue"); if (tb.Text != hf.Value) { SettingMgmt.saveSetting(lbl.Text, tb.Text); } } } BindData(); } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Settings.btnSave_Click", ex.Message, EventLogEntryType.Error); } }
public static DateTime FromUnixTime(string unixTime, bool ConvertToLocalTimezone = false) { try { Double longTime; bool converted = Double.TryParse(unixTime, out longTime); DateTime epoch = new DateTime(1970, 1, 1); epoch = epoch.AddSeconds(longTime); if (ConvertToLocalTimezone) { string strUsertimezone = SettingMgmt.getSetting("TimeZone-Adjuster"); string strWinktimezone = ConfigurationManager.AppSettings["WinkServerTimeZoneAdjustment"]; Int32 usertimezone = 0; Int32 winktimezone = 0; Int32.TryParse(strUsertimezone, out usertimezone); Int32.TryParse(strWinktimezone, out winktimezone); DateTime utcTime = epoch.ToUniversalTime(); epoch = utcTime.AddHours(usertimezone - winktimezone); if (DateTime.Now.IsDaylightSavingTime()) { epoch = epoch.AddHours(1); } } else { epoch = epoch.ToLocalTime(); } return(epoch); } catch (Exception ex) { return(DateTime.MinValue); throw; //EventLog.WriteEntry("WinkAtHome.Common.FromUnixTime", ex.Message, EventLogEntryType.Error); } }
protected void Page_Load(object sender, EventArgs e) { try { Common.prepareDatabase(); if (Session["_winkToken"] == null) { Response.Redirect("~/Login.aspx"); } if (!IsPostBack) { ibVersion.Text = Common.currentVersion; if (Common.isLocalHost) { bool hasUpdate = Common.checkForUpdate(); if (hasUpdate) { ibVersion.Text = "UPDATE AVAILABLE!"; ibVersion.Enabled = true; lblCurrentVersion.Text = Common.currentVersion; lblNewVersion.Text = Common.newVersion; tbReleaseNotes.Text = Common.updateNotes; hlDownloadUpdate.NavigateUrl = Common.updateFilePath; mpeUpdate.Show(); } } if (Common.isLocalHost) { rowBottomAds.Visible = false; rowMenuAdds.Visible = false; } lblRefreshed.Text = Common.getLocalTime().ToString(); //SET PAGE OPTIONS string timerrefresh = SettingMgmt.getSetting("RefreshTimer-" + Request.RawUrl.Replace("/", "").Replace(".aspx", "")); if (timerrefresh != null) { tbTimer.Text = timerrefresh; tmrRefresh.Interval = Convert.ToInt32(tbTimer.Text) * 60000; } string timerenabled = SettingMgmt.getSetting("RefreshEnabled-" + Request.RawUrl.Replace("/", "").Replace(".aspx", "")); if (timerenabled != null) { rblenabled.SelectedValue = timerenabled; tmrRefresh.Enabled = Convert.ToBoolean(rblenabled.SelectedValue); } string menustate = SettingMgmt.getSetting("Menu-Default-State"); if (menustate != null) { if (menustate == "hide") { tblCollapsed.Visible = true; tblExpand.Visible = false; } else { tblCollapsed.Visible = false; tblExpand.Visible = true; } cellMenu.BackColor = tblExpand.Visible ? System.Drawing.ColorTranslator.FromHtml("#eeeeee") : System.Drawing.ColorTranslator.FromHtml("#22b9ec"); } //SET PUBNUB //PubNub pubnub = PubNub.myPubNub; //if (pubnub.hasPubNub) //{ // pubnub.Open(); //} } } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Master.Page_Load", ex.Message, EventLogEntryType.Error); } }