/// <summary> /// Sends multiple email. /// </summary> /// <param name="From">Email sending from.</param> /// <param name="sendTo">Email sending to.</param> /// <param name="Subject">Email's subject.</param> /// <param name="Body">Email's body.</param> public static void SendMultipleEmail(string From, string sendTo, string Subject, string Body) { SageFrameConfig sfConfig = new SageFrameConfig(); string ServerPort = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPServer); string SMTPAuthentication = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPAuthentication); string SMTPEnableSSL = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPEnableSSL); string SMTPPassword = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPPassword); string SMTPUsername = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPUsername); string[] SMTPServer = ServerPort.Split(':'); try { MailMessage myMessage = new MailMessage(); foreach (string emailTo in sendTo.Split(',')) { myMessage.To.Add(new MailAddress(emailTo)); } myMessage.From = new MailAddress(From); myMessage.Subject = Subject; myMessage.Body = Body; myMessage.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); if (SMTPAuthentication == "1") { if (SMTPUsername.Length > 0 && SMTPPassword.Length > 0) { smtp.Credentials = new System.Net.NetworkCredential(SMTPUsername, SMTPPassword); } } smtp.EnableSsl = bool.Parse(SMTPEnableSSL.ToString()); if (SMTPServer.Length > 0) { if (SMTPServer[0].Length != 0) { smtp.Host = SMTPServer[0]; if (SMTPServer.Length == 2) { smtp.Port = int.Parse(SMTPServer[1]); } else { smtp.Port = 25; } smtp.Send(myMessage); } else { throw new Exception("SMTP Host must be provided"); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Adds contactus for given portalID. /// </summary> /// <param name="name">Name.</param> /// <param name="email">Email.</param> /// <param name="subject">Subject.</param> /// <param name="message">Message.</param> /// <param name="isActive">IsActive</param> /// <param name="portalID">Portal id.</param> /// <param name="addedBy">Added by.</param> public void ContactUsAdd(string name, string email, string subject, string message, bool isActive, int portalID, string addedBy) { try { ContactUsDataProvider contactProvider = new ContactUsDataProvider(); contactProvider.ContactUsAdd(name, email, message, isActive, portalID, addedBy); SageFrameConfig pagebase = new SageFrameConfig(); string emailSuperAdmin = pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.SuperUserEmail); string emailSiteAdmin = pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.SiteAdminEmailAddress); MailHelper.SendMailNoAttachment(email, emailSiteAdmin, subject, email, emailSuperAdmin, string.Empty); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { try { IncludeCss("PortalSettings", "/Modules/Admin/PortalSettings/css/popup.css"); if (!IsPostBack) { AddImageUrls(); BinDDls(); BindData(); SageFrameConfig sfConf = new SageFrameConfig(); ViewState["SelectedLanguageCulture"] = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultLanguage); GetLanguageList(); GetFlagImage(); } RoleController _role = new RoleController(); string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(','); if (!roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower())) { TabContainer.Tabs[2].Visible = false; TabContainer.Tabs[1].Visible = false; } } catch (Exception ex) { ProcessException(ex); } }
protected void Page_Load(object sender, EventArgs e) { appPath = GetApplicationName; SageFrameConfig pagebase = new SageFrameConfig(); LoadLiveFeed = bool.Parse(pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableLiveFeeds)); IncludeJs("SageFrameInfo", "/js/jquery.jgfeed-min.js"); IncludeCss("SageFrameInfo", "/Modules/Admin/SageFrameInfo/module.css"); }
private void LoadHeadContent() { try { SageFrameConfig sfConfig = new SageFrameConfig(); string strCPanleHeader = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalCopyright); litCPanlePortalCopyright.Text = strCPanleHeader; } catch (Exception ex) { ProcessException(ex); } }
/// <summary> /// Sets session tracker values for any thing requested URL. /// </summary> /// <param name="portalID">Portal ID.</param> /// <param name="userName">User's name.</param> public void SetSessionTrackerValues(string portalID, string userName) { SessionTracker sessionTracker = (SessionTracker)HttpContext.Current.Session[SessionKeys.Tracker]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = portalID; sessionTracker.Username = userName; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, userName, portalID); HttpContext.Current.Session[SessionKeys.Tracker] = sessionTracker; } }
protected void Page_Load(object sender, EventArgs e) { Extension = SageFrameSettingKeys.PageExtension; SageFrameConfig sfConf = new SageFrameConfig(); string PortalLogoTemplate = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalLogoTemplate); if (SageFrameSettingKeys.PortalLogoTemplate.ToString() != string.Empty) { lblSfInfo.Text = PortalLogoTemplate.ToString(); } if (!Page.IsPostBack) { DashBoardView(); } }
protected void Page_Load(object sender, EventArgs e) { IncludeLanguageJS(); appPath = GetApplicationName; SecurityPolicy objSecurity = new SecurityPolicy(); userName = objSecurity.GetUser(GetPortalID); Extension = SageFrameSettingKeys.PageExtension; if (!IsPostBack) { // BindThemes(); //BindLayouts(); //BindValues(); hlnkDashboard.Visible = false; SageFrameConfig conf = new SageFrameConfig(); string ExistingPortalShowProfileLink = conf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalShowProfileLink); lnkAccount.NavigateUrl = GetProfileLink(); if (ExistingPortalShowProfileLink == "1") { lnkAccount.Visible = true; } else { lnkAccount.Visible = false; } SageFrame.Application.Application app = new SageFrame.Application.Application(); lblVersion.Text = string.Format("V {0}", app.FormatShortVersion(app.Version, true)); } hypLogo.NavigateUrl = GetPortalAdminPage(); hypLogo.ImageUrl = appPath + "/Administrator/Templates/Default/images/sagecomers-logoicon.png"; RoleController _role = new RoleController(); string[] roles = _role.GetRoleNames(GetUsername, GetPortalID).ToLower().Split(','); if (roles.Contains(SystemSetting.SUPER_ROLE[0].ToLower()) || roles.Contains(SystemSetting.SITEADMIN.ToLower())) { hlnkDashboard.Visible = true; hlnkDashboard.NavigateUrl = GetPortalAdminPage(); cpanel.Visible = true; AspxAdminNotificationView1.Visible = true; IsAdmin = true; } else { cpanel.Visible = false; } }
public void RedirectToInvalid() { SageFrameConfig sfConfig = new SageFrameConfig(); string redirecPath = ""; if (!IsParent) { redirecPath = GetParentURL + "/portal/" + GetPortalSEOName + "/sf/" + sfConfig.GetSettingValueByIndividualKey( SageFrameSettingKeys.PortalPageNotAccessible) + SageFrameSettingKeys.PageExtension; } else { redirecPath = GetParentURL + "/sf/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalPageNotAccessible) + SageFrameSettingKeys.PageExtension; } Response.Redirect(redirecPath); }
public static string Results(string controlName) { try { SageFrameConfig sfConf = new SageFrameConfig(); string portalCulture = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultLanguage); if (HttpContext.Current.Session[SessionKeys.SageUICulture] != null) { Thread.CurrentThread.CurrentUICulture = (CultureInfo)HttpContext.Current.Session[SessionKeys.SageUICulture]; } else { CultureInfo newUICultureInfo = new CultureInfo(portalCulture); Thread.CurrentThread.CurrentUICulture = newUICultureInfo; HttpContext.Current.Session[SessionKeys.SageUICulture] = newUICultureInfo; } if (HttpContext.Current.Session[SessionKeys.SageUICulture] != null) { Thread.CurrentThread.CurrentCulture = (CultureInfo)HttpContext.Current.Session[SessionKeys.SageUICulture]; } else { CultureInfo newCultureInfo = new CultureInfo(portalCulture); Thread.CurrentThread.CurrentCulture = newCultureInfo; HttpContext.Current.Session[SessionKeys.SageUICulture] = newCultureInfo; } Page page = new Page(); SageUserControl userControl = (SageUserControl)page.LoadControl(controlName); page.Controls.Add(userControl); StringWriter textWriter = new StringWriter(); HttpContext.Current.Server.Execute(page, textWriter, false); return textWriter.ToString(); } catch (Exception ex) { return ex.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { SageFrameConfig objConfig = new SageFrameConfig(); bool EnableSessionTracker = bool.Parse(objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { IncludeJs("SiteAnalytics", "/Modules/SiteAnalytics/pjs/jquery.jqplot.min.js"); IncludeJs("SiteAnalytics", "/Modules/SiteAnalytics/pjs/excanvas.min.js"); IncludeJs("SiteAnalytics", "/Modules/SiteAnalytics/pjs/jqplot.pieRenderer.min.js"); IncludeCss("SiteAnalytics", "/Modules/SiteAnalytics/css/jquery.jqplot.css"); GetTopFiveCountryName(); hyLnkSiteAnalytics.NavigateUrl = GetHostURL() + "/Admin/Site-Analytics" + SageFrameSettingKeys.PageExtension; Flag = 1; } else { divtopFiveCountry.Visible = false; divMsg.Visible = true; lblMsg.InnerText = "Session tracker is not enable."; Flag = 0; } }
/// <summary> /// Checks if the requested request is from handheld device. /// </summary> /// <returns>Returns "True" if the device is handheld</returns> public bool IsHandheld() { SageFrameConfig sfConf = new SageFrameConfig(); string GetMode = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.UserAgentMode); bool status = false; if (GetMode == "3") { string strUserAgent = Request.UserAgent.ToString().ToLower(); if (strUserAgent != null) { if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("mobile")) //if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") || // strUserAgent.Contains("blackberry") || strUserAgent.Contains("mobile") || // strUserAgent.Contains("windows ce") || strUserAgent.Contains("opera mini") || // strUserAgent.Contains("palm")) { status = true; } } } else { int Mode = 0; Mode = int.Parse(GetMode); if (Mode == 2) { status = true; } else { status = false; } } return(status); }
protected void Page_Load(object sender, EventArgs e) { Extension = SageFrameSettingKeys.PageExtension; SageFrameConfig sfConfig = new SageFrameConfig(); SecurityPolicy objSecurity = new SecurityPolicy(); userName = objSecurity.GetUser(GetPortalID); if (!IsPostBack) { profileText = GetSageMessage("LoginStatus", "MyProfile"); Literal lnkProfileUrl = (Literal)LoginView1.TemplateControl.FindControl("lnkProfileUrl"); RegisterURL = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + SageFrameSettingKeys.PageExtension; if (sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalShowProfileLink) == "1") { if (!IsParent) { profileURL = "<a href='" + GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserProfilePage) + SageFrameSettingKeys.PageExtension + "'>" + profileText + "</a>"; } else { profileURL = "<a href='" + GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserProfilePage) + SageFrameSettingKeys.PageExtension + "'>" + profileText + "</a>"; } } else { profileURL = ""; } if (!IsParent) { RegisterURL = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + SageFrameSettingKeys.PageExtension; } else { RegisterURL = GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + SageFrameSettingKeys.PageExtension; } } }
private void BinDDls() { BindPageDlls(); Bindlistddls(); SageFrameConfig pagebase = new SageFrameConfig(); BindddlTimeZone(pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultLanguage)); BindRegistrationTypes(); BindYesNoRBL(); }
private void RestartApplication() { SageFrame.Application.Application app = new SageFrame.Application.Application(); File.SetLastWriteTime((app.ApplicationMapPath + "\\web.config"), System.DateTime.Now); SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie authenticateCookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID)); authenticateCookie.Expires = DateTime.Now.AddYears(-1); Response.Cookies.Add(authenticateCookie); System.Web.Security.FormsAuthentication.SignOut(); SetUserRoles(string.Empty); string redUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (!IsParent) { redUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension; } else { redUrl = GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension; } Response.Redirect(redUrl); }
public static string GetExtensions(int portalID, string userName, int userModuleID, string secureToken) { string extension = ""; AuthenticateService objService = new AuthenticateService(); if (objService.IsPostAuthenticatedView(portalID, userModuleID, userName, secureToken)) { SageFrameConfig config = new SageFrameConfig(); extension = config.GetSettingValueByIndividualKey(SageFrameSettingKeys.FileExtensions); } return extension; }
private void SetPageLoadPart() { #region "Unused Code" //string redirectPathLogin = "", redirectPathNoAccess = ""; //SageFrameConfig sfConfig = new SageFrameConfig(); //if (GetPortalID > 1) //{ // redirectPathLogin = // ResolveUrl("~/portal/" + GetPortalSEOName + "/sf/" + // sfConfig.GetSettingsByKey( // SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension); // redirectPathNoAccess = // ResolveUrl("~/portal/" + GetPortalSEOName + "/sf/" + // sfConfig.GetSettingsByKey( // SageFrameSettingKeys.PortalPageNotAccessible) + SageFrameSettingKeys.PageExtension); //} //else //{ // redirectPathLogin = ResolveUrl("~/sf/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension); // redirectPathNoAccess = ResolveUrl("~/sf/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalPageNotAccessible) + SageFrameSettingKeys.PageExtension); //} ltrJQueryLibrary.Text = GetAdminJqueryLibraryPath(); #endregion int UserModuleID = 0; if (Request.QueryString["uid"] != null) { UserModuleID = int.Parse(Request.QueryString["uid"].ToString()); } if (Request.QueryString["pid"] != null) { portalid = int.Parse(Request.QueryString["pid"].ToString()); } if (Request.QueryString["mdefID"] != null) { moduledefID = int.Parse(Request.QueryString["mdefID"].ToString()); } AuthenticateService objAuthenticate = new AuthenticateService(); if (objAuthenticate.IsPostAuthenticated(portalid, UserModuleID, GetUsername, SageFrameSecureToken)) { LoadModuleControls(UserModuleID); SetPortalCofig(); LoadMessageControl(); SetGlobalVariable(); } else { SageFrameConfig sfConfig = new SageFrameConfig(); string redirectPathNoAccess = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalPageNotAccessible) + SageFrameSettingKeys.PageExtension; Response.Redirect(redirectPathNoAccess); } }
protected void Page_Init(object sedner, EventArgs e) { SageFrameConfig sfConfig = new SageFrameConfig(); adminSidebarPosition = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.AdminSidebarPosition); }
/// <summary> /// Bundles all the css during loading time in one. /// </summary> protected void BundleCss() { string moduleList = string.Empty; if (HttpContext.Current.Session[SessionKeys.ModuleList] != null && HttpContext.Current.Session[SessionKeys.ModuleList].ToString() != string.Empty) { moduleList = HttpContext.Current.Session[SessionKeys.ModuleList].ToString(); } if (moduleList.Length > 0) { ///Check cache and refresh it if the files optimized folder do not exist ///Synchronize the cache and the map data in the files Hashtable hst = new Hashtable(); if (HttpRuntime.Cache[CacheKeys.SageFrameCss] != null) { hst = (Hashtable)HttpRuntime.Cache[CacheKeys.SageFrameCss]; } else { string optimizeMapfile = Server.MapPath("~/Optimized/map_css.xml"); XmlDocument doc = SageFrame.Templating.xmlparser.XmlHelper.LoadXMLDocument(optimizeMapfile); XmlNode xnresourcemap = doc.SelectSingleNode("resourcemaps"); XmlNodeList xnlist = xnresourcemap.ChildNodes; foreach (XmlNode node in xnlist) { string modules = node.SelectSingleNode("modules").InnerText; string map = node.SelectSingleNode("optimizeCSS").InnerText; if (modules != string.Empty && !hst.Contains(modules)) hst.Add(modules, map); } if (hst.Count > 0) { HttpRuntime.Cache[CacheKeys.SageFrameCss] = hst; } } string optimizeCssFileName = string.Empty; // Read the map file and check if the css for this combination already exists foreach (string modulekey in hst.Keys) { if (modulekey.Trim() != string.Empty && modulekey == moduleList) { optimizeCssFileName = hst[modulekey].ToString(); break; } } Literal litSageScript = Page.Header.FindControl("SageFrameModuleCSSlinks") as Literal; if ((optimizeCssFileName.Trim().Length > 0 && File.Exists(Server.MapPath(string.Format("~/Optimized/{0}.css", optimizeCssFileName))))) { LoadCssScripts(optimizeCssFileName, litSageScript); } else { string optimizedcss = string.Empty; string activeTemplate = GetActiveTemplate; List<CssScriptInfo> lstModuleResources = new List<CssScriptInfo>(); bool isAdmin = IsAdmin(); if (HttpContext.Current.Session[SessionKeys.ModuleCss] != null) { lstModuleResources = HttpContext.Current.Session[SessionKeys.ModuleCss] as List<CssScriptInfo>; } if (!isAdmin) { lstModuleResources.AddRange(CoreCss.GetTemplateCss(activeTemplate)); } List<KeyValue> lstCssInclude = new List<KeyValue>(); List<string> lstCss = new List<string>(); bool isTemplateDefault = Decide.IsTemplateDefault(activeTemplate); PresetInfo preset = GetPresetDetails; string templatePathFirst = isTemplateDefault ? "Core" : "Templates"; string templatePathSecond = isTemplateDefault ? "Template" : activeTemplate; #region "Get Modules Resources path" foreach (CssScriptInfo css in lstModuleResources) { lstCss.Add(css.ModuleName.ToLower()); string fullPath_theme = Server.MapPath(string.Format("~/{0}/{1}/themes/{2}/modules/{3}", templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName)); string fullPath_template = Server.MapPath(string.Format("~/{0}/{1}/modules/{2}", templatePathFirst, templatePathSecond, css.ModuleName)); string fullPath_module = Server.MapPath(string.Format("~/{0}", css.Path)); #region "Strategy 3-Priority-3:Check at the module level(the default fallback)" ///Strategy 3-Priority-3:Check at the module level(the default fallback) if (Directory.Exists(fullPath_module)) { ///Check to see if the file exists in the root level if (File.Exists(string.Format("{0}/{1}", fullPath_module, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}", css.Path, css.FileName), css.Path)); } ///Check to see if the file exists in the css folder else if (File.Exists(string.Format("{0}/css/{1}", fullPath_module, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}", css.Path, css.FileName), css.Path)); } } #endregion #region "Strategy 1-Priority-1:Check the themes" ///Strategy 1-Priority-1:Check the themes if (Directory.Exists(fullPath_theme)) { ///Check to see if the file exists in the root level if (File.Exists(fullPath_theme + "/" + css.FileName)) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/{4}", templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path)); } ///Check to see if the file exists in the css folder else if (File.Exists(string.Format("{0}/css/{1}", fullPath_theme, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/css/{4}", templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path)); } } #endregion #region "Strategy 2-Priority-2:Check at the template level" ///Strategy 2-Priority-2:Check at the template level else if (Directory.Exists(fullPath_template)) { ///Check to see if the file exists in the root level if (File.Exists(string.Format("{0}/{1}", fullPath_template, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path)); } ///Check to see if the file exists in the css folder else if (File.Exists(string.Format("{0}/css/{1}", fullPath_template, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/css/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path)); } } #endregion } #endregion string templateTypeName = isAdmin ? "admintemplate" : "template"; lstCss.Insert(0, templateTypeName); //#region "Synchronize the cache and the map data in the files" PresetInfo presetObj = GetPresetDetails; string uniqueid = GenerateUniqueId(); string optimized_css_path = Server.MapPath(string.Format("~/Optimized/{0}.css", uniqueid)); //Write the combination into the map file string optimizeMapfile = Server.MapPath("~/Optimized/map_css.xml"); XmlDocument doc = SageFrame.Templating.xmlparser.XmlHelper.LoadXMLDocument(optimizeMapfile); XmlNode xnresourcemap = doc.SelectSingleNode("resourcemaps"); XmlElement resourcemap = doc.CreateElement("resourcemap"); XmlElement modules = doc.CreateElement("modules"); XmlElement map = doc.CreateElement("optimizeCSS"); modules.InnerText = moduleList; map.InnerText = uniqueid; resourcemap.AppendChild(modules); resourcemap.AppendChild(map); xnresourcemap.AppendChild(resourcemap); doc.Save(optimizeMapfile); //adding the newly created value in the hash table and finally in cache if (hst[moduleList] == null) { hst.Add(moduleList, uniqueid); } HttpRuntime.Cache[CacheKeys.SageFrameCss] = hst; using (StreamWriter sw = new StreamWriter(optimized_css_path)) { ///Read the template.css file string compressedcss = string.Empty; string uncompcss = string.Empty; string jqueryUIPath = "/js/jquery-ui-1.8.14.custom/css/redmond/"; lstCssInclude.Add(new KeyValue("~" + jqueryUIPath + "jquery-ui-1.8.16.custom.css", jqueryUIPath)); //Insert the first css to be loaded if (!isAdmin && !IsHandheld()) { lstCssInclude.Insert(0, new KeyValue("~/Administrator/Templates/Default/css/normalize.css", "/Administrator/Templates/Default/css/")); lstCssInclude.Insert(1, new KeyValue("~/Administrator/Templates/Default/css/topstickybar.css", "/Administrator/Templates/Default/css/")); lstCssInclude.Insert(2, new KeyValue("~/Administrator/Templates/Default/css/grid.css", "/Administrator/Templates/Default/css/")); } else { lstCssInclude.Insert(0, new KeyValue("~/Administrator/Templates/Default/css/topstickybar.css", "/Administrator/Templates/Default/css/")); lstCssInclude.Insert(1, new KeyValue("~/Administrator/Templates/Default/css/grid.css", "/Administrator/Templates/Default/css/")); } ////Include the template css string templatecsspath = isAdmin ? GetAdminTemplatePath() : GetTemplateCssPath(); string imageWritePath = isTemplateDefault ? string.Format("/Core/Template/css") : string.Format("/Templates/{0}/css", activeTemplate); string imagerewrite = isAdmin ? "/Administrator/Templates/Default/css/" : imageWritePath; lstCssInclude.Add(new KeyValue(templatecsspath, imagerewrite)); //Include the responsive css if (!isAdmin) { string cssResponsivePath = GetResponsiveCssPath(); lstCssInclude.Add(new KeyValue(cssResponsivePath, imagerewrite)); } //Include the custom css string customCSSPath = GetCustomCSSPath(); lstCssInclude.Add(new KeyValue(customCSSPath, imagerewrite)); foreach (KeyValue cssfile in lstCssInclude) { using (StreamReader rdr = new StreamReader(Server.MapPath(cssfile.Key))) { uncompcss = rdr.ReadToEnd(); } compressedcss = CssJscriptOptimizer.Minifiers.CssMinifier.CssMinify(uncompcss); compressedcss = CssJscriptOptimizer.Minifiers.CssMinifier.RewriteCssImagePath(compressedcss, string.Format("{0}", cssfile.Value), GetAppPath(), "images"); sw.Write("\n"); sw.Write("/*-----" + Path.GetFileName(cssfile.Key) + "----*/"); sw.Write("\n"); sw.Write(compressedcss); sw.Write("\n"); } } LoadCssScripts(uniqueid, litSageScript); //Include the admin theme. } if (IsAdmin()) { SageFrameConfig sageConfig = new SageFrameConfig(); string defaultAdminTheme = sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.DefaultAdminTheme); string themeCssPath = "~/Administrator/Templates/Default/themes/" + defaultAdminTheme + ".css"; string css = "<link rel='stylesheet' href='" + ResolveUrl(string.Format(themeCssPath)) + "' type='text/css'></style>"; litSageScript.Text += css; } } }
/// <summary> /// Returns pageSEO name by page path /// </summary> /// <param name="pagePath"> opage path</param> /// <returns> Returns pageSEO name</returns> public string GetPageSEOName(string pagePath) { string SEOName = string.Empty; if (string.IsNullOrEmpty(pagePath)) { SageFrameConfig sfConfig = new SageFrameConfig(); SEOName = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultPage); } else { string[] pagePaths = pagePath.Split('/'); SEOName = pagePaths[pagePaths.Length - 1]; if (string.IsNullOrEmpty(SEOName)) { SEOName = pagePaths[pagePaths.Length - 2]; } SEOName = SEOName.Replace(SageFrameSettingKeys.PageExtension, ""); } return SEOName; }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text.Trim()); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); } { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); StoreSettingConfig ssc = new StoreSettingConfig(); if (ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, GetStoreID, GetPortalID, GetCurrentCultureName).ToLower() == "true") { RealTimeHelper.UpdateAdminNotifications(GetStoreID, GetPortalID); } // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; cookie.Expires = DateTime.Now.AddMinutes(expiryTime); Response.Cookies.Add(cookie); string sessionCode = string.Empty; ServiceSecurity.IssueToken(GetPortalID); if (HttpContext.Current.Session.SessionID != null) { sessionCode = HttpContext.Current.Session.SessionID.ToString(); } int CustomerID = GetUserDetailsByUserName(UserName.Text,GetPortalID).CustomerID; UpdateCartAnonymoususertoRegistered(GetStoreID, GetPortalID, CustomerID, sessionCode); if (!IsParent) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } } } } } }
void context_BeginRequest(object sender, EventArgs e) { string ext = SageFrameSettingKeys.PageExtension; HttpApplication AppObject = (HttpApplication)sender; if (!(AppObject.Request.CurrentExecutionFilePath.Contains("Templates/") || AppObject.Request.CurrentExecutionFilePath.Contains(".axd") || AppObject.Request.CurrentExecutionFilePath.Contains(".ashx") || AppObject.Request.CurrentExecutionFilePath.Contains(".asmx") || AppObject.Request.CurrentExecutionFilePath.Contains(".svc") || AppObject.Request.CurrentExecutionFilePath.Contains("fonts") || AppObject.Request.CurrentExecutionFilePath.Contains(".gif") || AppObject.Request.CurrentExecutionFilePath.Contains(".jpg") || AppObject.Request.CurrentExecutionFilePath.Contains(".js") || AppObject.Request.CurrentExecutionFilePath.Contains(".css") || AppObject.Request.CurrentExecutionFilePath.Contains(".png"))) { ApplicationController objAppController = new ApplicationController(); if (objAppController.IsInstalled()) { SageFrameConfig sfConf = new SageFrameConfig(); var _useSsl = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.UseSSL); bool useSSL = string.IsNullOrEmpty(_useSsl) ? false : bool.Parse(_useSsl.ToString().ToLower()); string serverName = HttpUtility.UrlEncode(AppObject.Request.ServerVariables["SERVER_NAME"]); string filePath = AppObject.Request.FilePath; string query = AppObject.Request.Url.Query; int portNo = AppObject.Request.Url.Port; string redirectionUrl = ""; string pagename = Path.GetFileName(filePath); pagename = pagename == "" ? "Home" : pagename; if (pagename.ToLower().Contains("loadcontrolhandler")) return; if (!AppObject.Request.IsSecureConnection) { if (useSSL) { redirectionUrl = "https://" + serverName + ":" + filePath + query; AppObject.Response.Redirect(redirectionUrl); return; } // send user to SSL if (portNo != 80) redirectionUrl = "https://" + serverName + ":" + portNo + filePath + query; else redirectionUrl = "https://" + serverName + filePath + query; if (checkIsPageSecure(pagename)) AppObject.Response.Redirect(redirectionUrl); } else { if (useSSL) return; if (portNo != 443) redirectionUrl = "http://" + serverName + ":" + portNo + filePath + query; else redirectionUrl = "http://" + serverName + filePath + query; if (!checkIsPageSecure(pagename)) AppObject.Response.Redirect(redirectionUrl); } } } }
/// <summary> /// Sends multiple emails. /// </summary> /// <param name="From">Email sending from.</param> /// <param name="sendTo">Email sending to</param> /// <param name="Subject">Email's subject</param> /// <param name="Body">Email's body</param> /// <param name="Identifiers">Email's identifiers</param> /// <param name="pageName">Page name</param> public static void SendMultipleEmail(string From, string sendTo, string Subject, string Body, string Identifiers, string pageName) { SageFrameConfig sfConfig = new SageFrameConfig(); string ServerPort = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPServer); string SMTPAuthentication = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPAuthentication); string SMTPEnableSSL = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPEnableSSL); string SMTPPassword = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPPassword); string SMTPUsername = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPUsername); string[] SMTPServer = ServerPort.Split(':'); try { MailMessage myMessage = new MailMessage(); List<string> lstTo = new List<string>(); List<string> lstidentity = new List<string>(); foreach (string emailTo in sendTo.Split(',')) { lstTo.Add(emailTo); myMessage.To.Add(new MailAddress(emailTo)); } foreach (string identity in Identifiers.Split(',')) { lstidentity.Add(identity); } SmtpClient smtp = new SmtpClient(); if (SMTPAuthentication == "1") { if (SMTPUsername.Length > 0 && SMTPPassword.Length > 0) { smtp.Credentials = new System.Net.NetworkCredential(SMTPUsername, SMTPPassword); } } smtp.EnableSsl = bool.Parse(SMTPEnableSSL.ToString()); if (SMTPServer.Length > 0) { if (SMTPServer[0].Length != 0) { smtp.Host = SMTPServer[0]; if (SMTPServer.Length == 2) { smtp.Port = int.Parse(SMTPServer[1]); } else { smtp.Port = 25; } int length = lstidentity.Count; for (int j = 0; j < length; j++) { try { myMessage.From = new MailAddress(From); myMessage.To.Add(lstTo[j]); myMessage.Subject = Subject; myMessage.Body = Body + "<br/><br/>if you want to unsubscribe click the link below <br/> " + pageName + "?id=" + lstidentity[j]; myMessage.IsBodyHtml = true; smtp.Send(myMessage); } catch (Exception e) { throw e; } } } else { throw new Exception("SMTP Host must be provided"); } } } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { IncludeLanguageJS(); Extension = SageFrameSettingKeys.PageExtension; SageFrameConfig sageConfig = new SageFrameConfig(); profileText = GetSageMessage("LoginStatus", "MyProfile"); Literal lnkProfileUrl = (Literal)LoginView1.TemplateControl.FindControl("lnkProfileUrl"); RegisterURL = sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + Extension; if (sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalShowProfileLink) == "1") { string profilepage = sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserProfilePage); profilepage = profilepage.ToLower().Equals("user-profile") ? string.Format("/sf/{0}", profilepage) : string.Format("/{0}", profilepage); if (!IsParent) { profileURL = "<a href='" + ResolveUrl(GetParentURL + "/portal/" + GetPortalSEOName + profilepage + Extension) + "'>" + profileText + "</a>"; } else { profileURL = "<a href='" + ResolveUrl(GetParentURL + profilepage + Extension) + "'>" + profileText + "</a>"; } } else { profileURL = string.Empty; } string userName = GetUsername; if (userName.ToLower() == "anonymoususer") { divAnonymousTemplate.Visible = true; divLoggedInTemplate.Visible = false; userName = "******"; } else { divAnonymousTemplate.Visible = false; divLoggedInTemplate.Visible = true; } // Label lblWelcomeMsg = LoginView1.FindControl("lblWelcomeMsg") as Label; // lblWelcomeMsg.Text = "<h2><span onload='GetMyLocale(this)'>Welcome " + userName + "!</span></h2>"; lblWelcomeMsg.Text = lblWelcomeMsg.Text + " " + userName; if (!IsParent) { RegisterURL = ResolveUrl(GetParentURL + "/portal/" + GetPortalSEOName + "/" + sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + Extension); } else { RegisterURL = ResolveUrl(GetParentURL + "/" + sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalRegistrationPage) + Extension); } int UserRegistrationType = sageConfig.GetSettingIntValueByIndividualKey(SageFrameSettingKeys.PortalUserRegistration); if (UserRegistrationType > 0) { RegisterURL = "<span><a href='" + RegisterURL + "'><i class=\"i-register\"></i>" + GetSageMessage("LoginStatus", "Register") + "</a></span>"; } else { RegisterURL = ""; } }
protected void imgSendEmail_Click(object sender, EventArgs e) { try { if (Page.IsValid) { string messageText = txtMessage1.Text; for (int i = 0; i < gdvLog.Rows.Count; i++) { GridViewRow row = gdvLog.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("chkSendEmail")).Checked; if (isChecked) { Literal exception = row.FindControl("ltrException") as Literal; Literal pageurl = row.FindControl("ltrPageUrl") as Literal; messageText += "<br/>" + pageurl.Text + "<br/>" + exception.Text; } } SageFrameConfig pagebase = new SageFrameConfig(); string emailSuperAdmin = pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.SuperUserEmail); string emailSiteAdmin = pagebase.GetSettingValueByIndividualKey(SageFrameSettingKeys.SiteAdminEmailAddress); MailHelper.SendMailNoAttachment(emailSiteAdmin, txtEmailAdd.Text, txtSubject1.Text, messageText, emailSuperAdmin, string.Empty); ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("EventViewer", "MailSentSuccessfully"), "", SageMessageType.Success); ClearEmailForm(); } } catch (Exception ex) { ProcessException(ex); } }
private string GetProfileLink() { string profileURL = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); string profilepage = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalUserProfilePage); profilepage = profilepage.ToLower().Equals("user-profile") ? string.Format("/sf/{0}", profilepage) : string.Format("/{0}", profilepage); profileURL = !IsParent ? string.Format("{0}/portal/{1}/{2}" + Extension, GetParentURL, GetPortalSEOName, profilepage) : string.Format("{0}/{1}" + Extension, GetParentURL, profilepage); return profileURL; }
public void LoadModuleCss() { string activeTemplate = GetActiveTemplate; List<CssScriptInfo> lstModuleResources = new List<CssScriptInfo>(); bool isAdmin = IsAdmin(); if (HttpContext.Current.Session[SessionKeys.ModuleCss] != null) { lstModuleResources = HttpContext.Current.Session[SessionKeys.ModuleCss] as List<CssScriptInfo>; } if (!isAdmin) { lstModuleResources.AddRange(CoreCss.GetTemplateCss(activeTemplate)); } List<KeyValue> lstCssInclude = new List<KeyValue>(); List<string> lstCss = new List<string>(); bool isTemplateDefault = Decide.IsTemplateDefault(activeTemplate); if (lstModuleResources != null) { PresetInfo preset = GetPresetDetails; string templatePathFirst = isTemplateDefault ? "Core" : "Templates"; string templatePathSecond = isTemplateDefault ? "Template" : activeTemplate; #region "Get Modules Resources path" foreach (CssScriptInfo css in lstModuleResources) { lstCss.Add(css.ModuleName.ToLower()); string fullPath_theme = Server.MapPath(string.Format("~/{0}/{1}/themes/{2}/modules/{3}", templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName)); string fullPath_template = Server.MapPath(string.Format("~/{0}/{1}/modules/{2}", templatePathFirst, templatePathSecond, css.ModuleName)); string fullPath_module = Server.MapPath(string.Format("~/{0}", css.Path)); #region "Strategy 3-Priority-3:Check at the module level(the default fallback)" ///Strategy 3-Priority-3:Check at the module level(the default fallback) if (Directory.Exists(fullPath_module)) { ///Check to see if the file exists in the root level if (File.Exists(string.Format("{0}/{1}", fullPath_module, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}", css.Path, css.FileName), css.Path)); } ///Check to see if the file exists in the css folder else if (File.Exists(string.Format("{0}/css/{1}", fullPath_module, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}", css.Path, css.FileName), css.Path)); } } #endregion #region "Strategy 1-Priority-1:Check the themes" ///Strategy 1-Priority-1:Check the themes if (Directory.Exists(fullPath_theme)) { ///Check to see if the file exists in the root level if (File.Exists(fullPath_theme + "/" + css.FileName)) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/{4}", templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path)); } ///Check to see if the file exists in the css folder else if (File.Exists(string.Format("{0}/css/{1}", fullPath_theme, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/themes/{2}/modules/{3}/css/{4}", templatePathFirst, templatePathSecond, preset.ActiveTheme, css.ModuleName, css.FileName), css.Path)); } } #endregion #region "Strategy 2-Priority-2:Check at the template level" ///Strategy 2-Priority-2:Check at the template level else if (Directory.Exists(fullPath_template)) { ///Check to see if the file exists in the root level if (File.Exists(string.Format("{0}/{1}", fullPath_template, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path)); } ///Check to see if the file exists in the css folder else if (File.Exists(string.Format("{0}/css/{1}", fullPath_template, css.FileName))) { lstCssInclude.Add(new KeyValue(string.Format("~/{0}/{1}/modules/{2}/css/{3}", templatePathFirst, templatePathSecond, css.ModuleName, css.FileName), css.Path)); } } #endregion } #endregion #region "Css Load" SageFrameConfig pagebase = new SageFrameConfig(); bool IsCompressCss = bool.Parse(pagebase.GetSettingsByKeyIndividual(SageFrameSettingKeys.OptimizeCss)); Literal SageFrameModuleCSSlinks = this.Page.FindControl("SageFrameModuleCSSlinks") as Literal; if (SageFrameModuleCSSlinks != null) { SageFrameModuleCSSlinks.Text = ""; foreach (KeyValue cssfile in lstCssInclude) { AddModuleCssToPage(cssfile.Key, SageFrameModuleCSSlinks); } if (IsUserLoggedIn()) { AddModuleCssToPage("~/js/jquery-ui-1.8.14.custom/css/redmond/jquery-ui-1.8.16.custom.css", SageFrameModuleCSSlinks); } SetTemplateCss(SageFrameModuleCSSlinks); if (isAdmin) { string cssColoredTemplate = string.Empty; SageFrameConfig sageConfig = new SageFrameConfig(); string defaultAdminTheme = sageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.DefaultAdminTheme); cssColoredTemplate = "~/Administrator/Templates/Default/themes/" + defaultAdminTheme + ".css"; AddModuleCssToPage(cssColoredTemplate, SageFrameModuleCSSlinks); } } #endregion } }
protected void LoginButton_Click(object sender, EventArgs e) { MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); if (user.UserExists && user.IsApproved) { if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(PasswordAspx.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, PasswordAspx.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); SecurityPolicy objSecurity = new SecurityPolicy(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; cookie.Expires = DateTime.Now.AddMinutes(expiryTime); Response.Cookies.Add(cookie); ServiceSecurity.IssueToken(GetPortalID); if (Request.QueryString["ReturnUrl"] != null) { string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append(GetParentURL); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { if (!IsParent) { redirectURL.Append(GetParentURL); redirectURL.Append("/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(ssc.GetStoreSettingsByKey(StoreSetting.SingleCheckOutURL, GetStoreID, GetPortalID, GetCurrentCultureName)); redirectURL.Append(SageFrameSettingKeys.PageExtension); } else { redirectURL.Append(GetParentURL); redirectURL.Append("/"); redirectURL.Append(ssc.GetStoreSettingsByKey(StoreSetting.SingleCheckOutURL, GetStoreID, GetPortalID, GetCurrentCultureName)); redirectURL.Append(SageFrameSettingKeys.PageExtension); } } int customerID = GetCustomerID; if (customerID == 0) { CustomerGeneralInfo sageUserCust = CustomerGeneralInfoController.CustomerIDGetByUsername(user.UserName, storeID, portalID); if (sageUserCust != null) { customerID = sageUserCust.CustomerID; } } AspxCommonController objCommonCont = new AspxCommonController(); objCommonCont.UpdateCartAnonymoususertoRegistered(storeID, portalID, customerID, sessionCode); Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal")); } } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!"; } } } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UserDoesnotExist")); } }
/// <summary> /// Initialize Culture /// </summary> protected override void InitializeCulture() { ApplicationController objAppController = new ApplicationController(); if (objAppController.IsInstalled()) { SageFrameConfig sfConf = new SageFrameConfig(); string portalCulture = sfConf.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalDefaultLanguage); if (Session[SessionKeys.SageUICulture] != null) { Thread.CurrentThread.CurrentUICulture = (CultureInfo)Session[SessionKeys.SageUICulture]; } else { CultureInfo newUICultureInfo = new CultureInfo(portalCulture); Thread.CurrentThread.CurrentUICulture = newUICultureInfo; Session[SessionKeys.SageUICulture] = newUICultureInfo; } if (Session[SessionKeys.SageUICulture] != null) { Thread.CurrentThread.CurrentCulture = (CultureInfo)Session[SessionKeys.SageUICulture]; } else { CultureInfo newCultureInfo = new CultureInfo(portalCulture); Thread.CurrentThread.CurrentCulture = newCultureInfo; Session[SessionKeys.SageUICulture] = newCultureInfo; } } else { HttpContext.Current.Response.Redirect(ResolveUrl("~/Install/InstallWizard.aspx")); } base.InitializeCulture(); }
private void PreviewAds() { AdUnit1.Visible = true; SageFrameConfig pb = new SageFrameConfig(); AdUnit1.AffiliateId = pb.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalGoogleAdSenseID); string unitFormat = ddlUnitFormat.SelectedItem.Text; string unitType = ddlAddType.SelectedItem.Text; if (Enum.IsDefined(typeof(AdUnitFormat), unitFormat)) { AdUnit1.AdUnitFormat = (AdUnitFormat)Enum.Parse(typeof(AdUnitFormat), unitFormat, true); } if (Enum.IsDefined(typeof(AdUnitType), unitType)) { AdUnit1.AdUnitType = (AdUnitType)Enum.Parse(typeof(AdUnitType), unitType, true); } AdUnit1.ChannelId = txtChannelID.Text; if (txtbackcolor.Text.Trim() != "") { AdUnit1.BackColor = System.Drawing.ColorTranslator.FromHtml("#" + txtbackcolor.Text.Trim()); } if (txtLink.Text.Trim() != "") { AdUnit1.LinkColor = System.Drawing.ColorTranslator.FromHtml("#" + txtLink.Text.Trim()); } if (txtText.Text.Trim() != "") { AdUnit1.TextColor = System.Drawing.ColorTranslator.FromHtml("#" + txtText.Text.Trim()); } if (txtBorder.Text.Trim() != "") { AdUnit1.BorderColor = System.Drawing.ColorTranslator.FromHtml("#" + txtBorder.Text.Trim()); } if (txtURL.Text.Trim() != "") { AdUnit1.UrlColor = System.Drawing.ColorTranslator.FromHtml("#" + txtURL.Text.Trim()); } if (ddlAlternateAds.SelectedValue != "-1") { AdUnit1.AlternateAdType = (AlternateAdTypes)Enum.Parse(typeof(AlternateAdTypes), ddlAlternateAds.SelectedItem.Text, true); if (ddlAlternateAds.SelectedValue == "1") { AdUnit1.AnotherUrl = txtanotherURL.Text.Trim(); } else if (ddlAlternateAds.SelectedValue == "2") { if (txtSolidFill.Text.Trim() != "") { AdUnit1.SolidFillColor = System.Drawing.ColorTranslator.FromHtml("#" + txtSolidFill.Text.Trim()); } else { AdUnit1.SolidFillColor = System.Drawing.ColorTranslator.FromHtml("#fffff"); } } } }
/// <summary> /// Sends mail with multiple attachment files /// </summary> /// <param name="From">Email from.</param> /// <param name="sendTo">Email to.</param> /// <param name="Subject">Email's subject.</param> /// <param name="Body">Email's body.</param> /// <param name="AttachmentFiles">Array of attachment files path.</param> /// <param name="CC">Email CC to.</param> /// <param name="BCC">EMail BCC to.</param> /// <param name="IsHtmlFormat">Set true if the body must be in HTML format.</param> public static void SendEMail(string From, string sendTo, string Subject, string Body, ArrayList AttachmentFiles, string CC, string BCC, bool IsHtmlFormat) { SageFrameConfig sfConfig = new SageFrameConfig(); string ServerPort = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPServer); string SMTPAuthentication = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPAuthentication); string SMTPEnableSSL = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPEnableSSL); string SMTPPassword = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPPassword); string SMTPUsername = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.SMTPUsername); string[] SMTPServer = ServerPort.Split(':'); try { MailMessage myMessage = new MailMessage(); myMessage.To.Add(sendTo); myMessage.From = new MailAddress(From); myMessage.Subject = Subject; myMessage.Body = Body; myMessage.IsBodyHtml = true; if (CC.Length != 0) myMessage.CC.Add(CC); if (BCC.Length != 0) myMessage.Bcc.Add(BCC); if (AttachmentFiles != null) { foreach (string x in AttachmentFiles) { if (File.Exists(x)) myMessage.Attachments.Add(new Attachment(x)); } } SmtpClient smtp = new SmtpClient(); if (SMTPAuthentication == "1") { if (SMTPUsername.Length > 0 && SMTPPassword.Length > 0) { smtp.Credentials = new System.Net.NetworkCredential(SMTPUsername, SMTPPassword); } } smtp.EnableSsl = bool.Parse(SMTPEnableSSL.ToString()); if (SMTPServer.Length > 0) { if (SMTPServer[0].Length != 0) { smtp.Host = SMTPServer[0]; if (SMTPServer.Length == 2) { smtp.Port = int.Parse(SMTPServer[1]); } else { smtp.Port = 25; } smtp.Send(myMessage); } else { throw new Exception("SMTP Host must be provided"); } } } catch (Exception ex) { throw ex; } }
protected void SucessFullLogin(UserInfo user) { RoleController role = new RoleController(); Session[SessionKeys.LoginHitCount] = null; string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); SecurityPolicy objSecurity = new SecurityPolicy(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); //generate random cookieValue string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; //create new cookie with random cookie name and encrypted ticket HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); //get default time from setting SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; //set cookie expiry time cookie.Expires = DateTime.Now.AddMinutes(expiryTime); //add cookie to the browser Response.Cookies.Add(cookie); ServiceSecurity.IssueToken(GetPortalID); if (Request.QueryString["ReturnUrl"] != null) { string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = string.Empty; if (Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString().Contains(GetHostURL())) { ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); } else { ReturnUrlPage = GetHostURL() + Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); } string RequestURL = Request.Url.ToString(); Uri RequestURLPageUri = new Uri(RequestURL); string portalHostURL = RequestURLPageUri.AbsolutePath.TrimStart('/'); if (GetApplicationName==string.Empty) { bool IsWellFormedReturnUrlPage = Uri.IsWellFormedUriString(ReturnUrlPage, UriKind.Absolute); if (IsWellFormedReturnUrlPage) { Uri ReturnUrlPageUri = new Uri(ReturnUrlPage); string ReturnURl = ReturnUrlPageUri.Scheme + Uri.SchemeDelimiter + ReturnUrlPageUri.Host + ":" + ReturnUrlPageUri.Port; string HostUrl = GetHostURL(); Uri uriHostURL = new Uri(HostUrl); Uri uriReturnURL = new Uri(ReturnURl); var resultCompareURL = Uri.Compare(uriHostURL, uriReturnURL, UriComponents.Host | UriComponents.PathAndQuery, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); int resultComparePortalURL = 0; if (portalHostURL.ToLower().Contains("portal") && resultCompareURL == 0) { Uri ReturnUrlPageHostUri = new Uri(ReturnUrlPage); string portalReturnURL = ReturnUrlPageHostUri.AbsolutePath.TrimStart('/'); string[] portalReturnURLSplit = portalReturnURL.Split('/'); string ReturnURLSplitPortal = portalReturnURLSplit[0]; string ReturnURLSplitPortalName = portalReturnURLSplit[1]; string ReturnURLWithPortal = ReturnURLSplitPortal + "/" + ReturnURLSplitPortalName; string[] portalHostURLSplit = portalHostURL.Split('/'); string HostURLSplitPortal = portalHostURLSplit[0]; string HostURLSplitPortalName = portalHostURLSplit[1]; string HostURLWithPortal = HostURLSplitPortal + "/" + HostURLSplitPortalName; resultComparePortalURL = string.Compare(ReturnURLWithPortal, HostURLWithPortal); } if (resultCompareURL != 0 || resultComparePortalURL != 0) { PageNotFoundURL(); } } else { PageNotFoundURL(); } } if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append(GetParentURL); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { if (!IsParent) { redirectURL.Append(GetParentURL); redirectURL.Append("/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(GetParentURL); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } } HttpContext.Current.Session[SessionKeys.IsLoginClick] = true; if (Session[SessionKeys.LoginHitCount] != null) { HttpContext.Current.Session.Remove(SessionKeys.LoginHitCount); } Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));//"You are not authenticated to this portal!"; } }