void Page_PreInit(object sender, EventArgs e) { context = new EntitiesContext(); portals = new Portals(context); //////Set PortalID override //Session["PortalID"] = 2; //PROJECT=BLL&NAMESPACE=BLL.Store&CLASS=Category&METHOD=StoreCategoryList //PROJECT=BLL&NAMESPACE=BLL&CLASS=Content&METHOD=ReadContent&PARAMS=Home.aspx,IsAjax //////Auto login if (Session["UserID"] == null) { BLL.Users.Login("*****@*****.**", "*****@*****.**"); } var values = new Hashtable(); values = portals.GetSiteConfig(); if (values["MasterPage"] != null) { MasterPageFile = "~/App_Master/" + values["MasterPage"].ToString(); } if (values["StartMethod"] != null) { StartMethod = values["StartMethod"].ToString(); } }
/// <summary> /// /// </summary> /// <param name="entityKey"></param> public static void Delete(int entityKey) { using (var context = new EntitiesContext()) { DAL.PortalAlia r = context.PortalAlias.Single(p => p.PortalAliasID == entityKey); context.DeleteObject(r); context.SaveChanges(); } }
/// <summary> /// Fetches Portal Alias information /// </summary> /// <returns>Returns a list with EntityKey, HttpAlias, PortalID, and the Portal Name</returns> public static IQueryable DataSource() { using (var context = new EntitiesContext()) { var query = from _PortalAlias in context.PortalAlias join _Portals in context.Portals on _PortalAlias.PortalID equals _Portals.PortalID select new { EntityKey = _PortalAlias.PortalAliasID, _PortalAlias.HTTPAlias, _PortalAlias.PortalID, PortalName = _Portals.Name }; return query; } }
public static void AddStoreProduct(string PARAMS = null) { string[] VALUES = null; int _CartID = GetCartID(); int _ProductID = 0; if (PARAMS != null) { VALUES = PARAMS.Split(','); if (VALUES[0] != null) { _ProductID = int.Parse(VALUES[0].ToString()); } } using (EntitiesContext context = new EntitiesContext()) { context.usp_StoreInsertCartItem(_CartID, 1, _ProductID, Product.PortalID); } }
public void ProcessRequest(HttpContext _context) { StringBuilder sb = new StringBuilder(); Int32 PortalID; string RobotsText; using (EntitiesContext context = new EntitiesContext()) { var P = context.PortalAlias.Single(p => p.HTTPAlias == HttpContext.Current.Request.Url.Host); PortalID = P.PortalID; } using (EntitiesContext context = new EntitiesContext()) { var P = context.Portals.Single(p => p.PortalID == PortalID); RobotsText = P.RobotsText; } byte[] bytes = StrToByteArray(RobotsText); WriteFile(bytes, "text/plain", _context.Response); }
/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that /// implements the <see cref="T:System.Web.IHttpHandler"></see> interface. /// </summary> /// <param name="response"> /// An <see cref="T:System.Web.HttpContext"></see> /// object that provides references to the intrinsic server objects /// (for example, Request, Response, Session, and Server) used to service HTTP requests. /// </param> public void ProcessRequest(HttpContext response) { using (var writer = XmlWriter.Create(response.Response.OutputStream)) { writer.WriteStartElement("urlset", "http://www.google.com/schemas/sitemap/0.84"); try { using (EntitiesContext context = new EntitiesContext()) { var query = from q in context.Contents where q.PortalID == this.PortalID & q.IsPublished == true select q; foreach (var c in query) { writer.WriteStartElement("url"); writer.WriteElementString("loc", string.Format("{0}Pages/" + c.URL, Utils.ReturnRootUrl())); writer.WriteElementString("lastmod", DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); writer.WriteElementString("changefreq", "monthly"); writer.WriteEndElement(); } } } catch (Exception ex) { ElmahExtension.LogToElmah(ex); } writer.WriteEndElement(); } response.Response.ContentType = "text/xml"; }
/// <summary> /// Content RadTable functions /// </summary> public static Hashtable GetProduct(int EntityKey) { var values = new Hashtable(); using (EntitiesContext context = new EntitiesContext()) { var query = from q in Utils.DbContext.StoreProducts where q.PortalID == Product.PortalID & q.ProductID == EntityKey select new { q.ProductID, q.CategoryID, q.Name, q.Description, q.Published, q.Deleted, q.Price }; foreach (var i in query) { values["ProductID"] = i.ProductID; values["CategoryID"] = i.CategoryID; values["Name"] = i.Name; values["Description"] = i.Description; values["Published"] = i.Published; values["Deleted"] = i.Deleted; values["Price"] = i.Price; } } return values; }
public static string ReadContentListView() { StringBuilder sb = new StringBuilder(); string[] file = HttpContext.Current.Request.CurrentExecutionFilePath.Split('/'); string fileName = file[file.Length - 1]; try { sb.Append(@"<div data-role=""collapsible"">"); sb.Append(@"<h3>More in this section</h3>"); sb.Append(@"<ul data-role=""listview"">"); using (EntitiesContext context = new EntitiesContext()) { var query = from q in context.Contents where q.PortalID == Content.PortalID & q.IsPublished == true & q.IsMenu == true & q.ContentTypeID == 1 orderby q.DisplayOrder select q; foreach (var c in query) { if (c.StartMethod == null || c.StartMethod == "") { string[] array = { c.URL, "IsAjax" }; string PARAMS = String.Join(",", array); sb.Append(@"<li><a onclick=""makePOSTRequest('section_body', 'PROJECT=BLL&NAMESPACE=BLL&CLASS=Content&METHOD=ReadContent&PARAMS="); sb.Append(PARAMS); sb.Append(String.Format(@"');"">{0}</a></li>", c.Title)); } else { sb.Append(@"<li><a onclick=""makePOSTRequest('section_body', '"); sb.Append(c.StartMethod); sb.Append(String.Format(@"');"">{0}</a></li>", c.Title)); } } } sb.Append(@"</ul></div>"); } catch (Exception ex) { ElmahExtension.LogToElmah(ex); } return sb.ToString(); }
public static string ReturnStoreProduct(string PARAMS = null) { StringBuilder sb = new StringBuilder(); string[] VALUES = null; string PARAM1 = null; int ProductID = 0; if (PARAMS != null) { VALUES = PARAMS.Split(','); if (VALUES[0] != null) { PARAM1 = VALUES[0].ToString(); ProductID = int.Parse(PARAM1); } } using (EntitiesContext context = new EntitiesContext()) { var R = context.StoreProducts.Single(q => q.ProductID == ProductID & q.PortalID == Product.PortalID); sb.Append(@"<div style=""font-weight: bold"">"); sb.Append(R.Name + " - " + String.Format("{0:C}", R.Price)); sb.Append(@"</div><div>" + R.Description + @"</div><hr />"); //sb.Append(@"<div data-role=""fieldcontain"">"); //sb.Append(@"<a href=""#"" data-role=""button"" data-icon=""plus"">Add to Cart</a>"); //sb.Append(@"</div>"); } return sb.ToString(); }
public Portals(EntitiesContext context) { this.context = context; }
/// <summary> /// Content RadTable functions /// </summary> public static Hashtable GetStoreCategory(int EntityKey) { var values = new Hashtable(); using (EntitiesContext context = new EntitiesContext()) { var query = from q in Utils.DbContext.StoreCategories where q.PortalID == Category.PortalID & q.CategoryID == EntityKey select new { q.ParentCategoryId, q.Deleted, q.IsMenu }; foreach (var i in query) { values["ParentCategoryId"] = i.ParentCategoryId; values["Deleted"] = i.Deleted; values["IsMenu"] = i.IsMenu; } } return values; }
public static string GetADOConnectionString() { var db = new EntitiesContext(); EntityConnection ec = (EntityConnection)db.Connection; return ec.StoreConnection.ConnectionString; }
/// <summary> /// Content RadTable functions /// </summary> public static Hashtable GetSurveyQuestion(int EntityKey) { var values = new Hashtable(); using (EntitiesContext context = new EntitiesContext()) { var query = from q in Utils.DbContext.SurveyQuestions where q.QuestionID == EntityKey select new { q.QuestionID, q.SurveyID, q.AnswerGroupID, q.Question, q.IsDeleted }; foreach (var i in query) { values["QuestionID"] = i.QuestionID; values["SurveyID"] = i.SurveyID; values["AnswerGroupID"] = i.AnswerGroupID; values["Question"] = i.Question; values["IsDeleted"] = i.IsDeleted; } } return values; }
public void CreateItem(string name, string path, string mimeType, bool isDirectory, long size, byte[] content) { int parentId = GetItemId(path); if (parentId < 0) { return; } using (EntitiesContext context = new EntitiesContext()) { ContentFile I = new ContentFile { Name = name, ParentID = parentId, MimeType = mimeType, IsDirectory = isDirectory, Size = int.Parse(size.ToString()), FileContent = content, PortalID = this.PortalID }; context.ContentFiles.AddObject(I); context.SaveChanges(); } _data = null; }
public void DeleteItem(string path) { //TODO: cascade delete when removing a non-empty folder int itemId = GetItemId(path); if (itemId <= 0) { return; } using (EntitiesContext context = new EntitiesContext()) { //dynamic I = context.ContentFiles.FirstOrDefault(i => i.FileID == itemId & i.PortalID == Portals.PortalID); dynamic I = context.ContentFiles.FirstOrDefault(i => i.FileID == itemId); context.ContentFiles.DeleteObject(I); context.SaveChanges(); } _data = null; }
public static void InsertResponse(string ResponseIN) { if (ConfigurationManager.AppSettings.Get("PayPalSubmitUrl") != null) { try { string Environment = null; if (ConfigurationManager.AppSettings.Get("PayPalSubmitUrl") == "https://www.sandbox.paypal.com/cgi-bin/webscr") { Environment = "PayPalSandBox"; } if (ConfigurationManager.AppSettings.Get("PayPalSubmitUrl") == "https://www.paypal.com/cgi-bin/webscr") { Environment = "PayPalProduction"; } using (EntitiesContext context = new EntitiesContext()) { DAL.IPN I = new DAL.IPN { CreateDate = DateTime.Now, Environment = Environment, ResponseIN = ResponseIN }; context.IPNs.AddObject(I); context.SaveChanges(); ParseResponse(ResponseIN, I.IPNID); } } catch (Exception ex) { ElmahExtension.LogToElmah(ex); } } else { ElmahExtension.LogToElmah(new ApplicationException("Unable to read the value PayPalSubmitUrl in web.config file")); } }
public static byte[] GetContent(string path) { int fileID = GetItemId(path); if (fileID <= 0) { return null; } byte[] returnValue = null; using (EntitiesContext context = new EntitiesContext()) { //var result = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID & i.PortalID == Portals.PortalID); //var result = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID); var result = context.ContentFiles.Single(i => i.FileID == fileID); returnValue = result.FileContent; } return returnValue; }
public static void ParseResponse(string ResponseIN, int IPNID) { NameValueCollection PayPal_Args = HttpUtility.ParseQueryString(ResponseIN); using (EntitiesContext context = new EntitiesContext()) { var i = context.IPNs.FirstOrDefault(s => s.IPNID == IPNID); if (i != null) { if (PayPal_Args["txn_id"] != null) { i.txn_id = PayPal_Args["txn_id"]; } if (PayPal_Args["mc_gross"] != null) { i.mc_gross = decimal.Parse(PayPal_Args["mc_gross"]); } if (PayPal_Args["tax"] != null) { i.tax = decimal.Parse(PayPal_Args["tax"]); } if (PayPal_Args["protection_eligibility"] != null) { i.protection_eligibility = PayPal_Args["protection_eligibility"]; } if (PayPal_Args["address_status"] != null) { i.address_status = PayPal_Args["address_status"]; } if (PayPal_Args["payer_id"] != null) { i.payer_id = PayPal_Args["payer_id"]; } if (PayPal_Args["first_name"] != null) { i.first_name = PayPal_Args["first_name"]; } if (PayPal_Args["last_name"] != null) { i.last_name = PayPal_Args["last_name"]; } if (PayPal_Args["address_street"] != null) { i.address_street = PayPal_Args["address_street"]; } if (PayPal_Args["payment_date"] != null) { i.payment_date = PayPal_Args["payment_date"]; } if (PayPal_Args["payment_status"] != null) { i.payment_status = PayPal_Args["payment_status"]; } if (PayPal_Args["charset"] != null) { i.charset = PayPal_Args["charset"]; } if (PayPal_Args["address_zip"] != null) { i.address_zip = int.Parse(PayPal_Args["address_zip"]); } if (PayPal_Args["mc_fee"] != null) { i.mc_fee = decimal.Parse(PayPal_Args["mc_fee"]); } if (PayPal_Args["address_country_code"] != null) { i.address_country_code = PayPal_Args["address_country_code"]; } if (PayPal_Args["address_name"] != null) { i.address_name = PayPal_Args["address_name"]; } if (PayPal_Args["notify_version"] != null) { i.notify_version = decimal.Parse(PayPal_Args["notify_version"]); } if (PayPal_Args["custom"] != null) { i.custom = PayPal_Args["custom"]; } if (PayPal_Args["payer_status"] != null) { i.payer_status = PayPal_Args["payer_status"]; } if (PayPal_Args["business"] != null) { i.business = PayPal_Args["business"]; } if (PayPal_Args["address_country"] != null) { i.address_country = PayPal_Args["address_country"]; } if (PayPal_Args["address_city"] != null) { i.address_city = PayPal_Args["address_city"]; } if (PayPal_Args["quantity"] != null) { i.quantity = int.Parse(PayPal_Args["quantity"]); } if (PayPal_Args["verify_sign"] != null) { i.verify_sign = PayPal_Args["verify_sign"]; } if (PayPal_Args["payer_email"] != null) { i.payer_email = PayPal_Args["payer_email"]; } if (PayPal_Args["payment_type"] != null) { i.payment_type = PayPal_Args["payment_type"]; } if (PayPal_Args["address_state"] != null) { i.address_state = PayPal_Args["address_state"]; } if (PayPal_Args["receiver_email"] != null) { i.receiver_email = PayPal_Args["receiver_email"]; } if (PayPal_Args["payment_fee"] != null) { i.payment_fee = decimal.Parse(PayPal_Args["payment_fee"]); } if (PayPal_Args["receiver_id"] != null) { i.receiver_id = PayPal_Args["receiver_id"]; } if (PayPal_Args["txn_type"] != null) { i.txn_type = PayPal_Args["txn_type"]; } if (PayPal_Args["item_name"] != null) { i.item_name = PayPal_Args["item_name"]; } if (PayPal_Args["mc_currency"] != null) { i.mc_currency = PayPal_Args["mc_currency"]; } if (PayPal_Args["item_number"] != null) { i.item_number = PayPal_Args["item_number"]; } if (PayPal_Args["residence_country"] != null) { i.residence_country = PayPal_Args["residence_country"]; } if (PayPal_Args["test_ipn"] != null) { i.test_ipn = PayPal_Args["test_ipn"]; } if (PayPal_Args["handling_amount"] != null) { i.handling_amount = decimal.Parse(PayPal_Args["handling_amount"]); } if (PayPal_Args["transaction_subject"] != null) { i.transaction_subject = PayPal_Args["transaction_subject"]; } if (PayPal_Args["payment_gross"] != null) { i.payment_gross = decimal.Parse(PayPal_Args["payment_gross"]); } if (PayPal_Args["shipping"] != null) { i.shipping = decimal.Parse(PayPal_Args["shipping"]); } if (PayPal_Args["ipn_track_id"] != null) { i.ipn_track_id = PayPal_Args["ipn_track_id"]; } try { i.LastUpdated = DateTime.Now; i.ResponseParsed = true; context.SaveChanges(); } catch (Exception ex) { i.ResponseParsed = false; context.SaveChanges(); ElmahExtension.LogToElmah(ex); } } } }
protected void Page_Init(object sender, EventArgs e) { this.context = new EntitiesContext(); this.roles = new BLL.Roles(context); }
public static string StoreCategoryList() { StringBuilder sb = new StringBuilder(); try { sb.Append(@"<ul data-role=""listview"" data-inset=""true"">"); using (EntitiesContext context = new EntitiesContext()) { var query = from _StoreCategories in context.StoreCategories where _StoreCategories.PortalID == Category.PortalID orderby _StoreCategories.DisplayOrder select _StoreCategories; foreach (var c in query) { string[] array = { c.Name, "IsAjax" }; string PARAMS = String.Join(",", array); sb.Append(@"<li><a onclick=""makePOSTRequest('section_body', 'PROJECT=BLL&NAMESPACE=BLL.Store&CLASS=Product&METHOD=ReturnStoreProducts&PARAMS="); sb.Append(PARAMS); sb.Append(String.Format(@"');"">{0}</a></li>", c.Name)); } } sb.Append(@"</ul>"); } catch (Exception ex) { ElmahExtension.LogToElmah(ex); } return sb.ToString(); }
public static void InsertLog(int _ClientHeight, int _ClientWidth, string _FileName, bool _Ajax) { try { string _Host = HttpContext.Current.Request.Url.Host; int _UserID = 0; HttpBrowserCapabilities r = HttpContext.Current.Request.Browser; if (HttpContext.Current.Session["UserID"] != null) { _UserID = (int)HttpContext.Current.Session["UserID"]; } using (EntitiesContext context = new EntitiesContext()) { DAL.SiteLog L = new DAL.SiteLog { PortalID = SiteLog.PortalID, CreateDate = DateTime.Now, UserID = _UserID, Ajax = _Ajax, Host = _Host, FileName = _FileName.Replace("ACTION=", "/"), RequestRequestType = HttpContext.Current.Request.RequestType, RequestUserHostAddress = HttpContext.Current.Request.UserHostAddress, RequestUserHostName = HttpContext.Current.Request.UserHostName, RequestHttpMethod = HttpContext.Current.Request.HttpMethod, ClientHeight = _ClientHeight, ClientWidth = _ClientWidth, Browser = r.Browser, BrowserType = r.Type, BrowserVersion = decimal.Parse(r.Version), BrowserMajorVersion = r.MajorVersion, BrowserPlatform = r.Platform, BrowserCrawler = r.Crawler, BrowserFrames = r.Frames, BrowserTables = r.Tables, BrowserCookies = r.Cookies, BrowserVBScript = r.VBScript, BrowserEcmaScriptVersion = decimal.Parse(r.EcmaScriptVersion.ToString()), BrowserJavaApplets = r.JavaApplets, BrowserActiveXControls = r.ActiveXControls, BrowserJavaScriptVersion = decimal.Parse(r["JavaScriptVersion"]) }; context.SiteLogs.AddObject(L); context.SaveChanges(); } } catch (Exception ex) { ElmahExtension.LogToElmah(ex); } }
public static string ReturnStoreProducts(string PARAMS = null) { StringBuilder sb = new StringBuilder(); string[] VALUES = null; string PARAM1 = null; if (PARAMS != null) { VALUES = PARAMS.Split(','); if (VALUES[0] != null) { PARAM1 = VALUES[0].ToString(); } } sb.Append(@"<h1>"); sb.Append(PARAM1); sb.Append(@"</h1><hr />"); using (EntitiesContext context = new EntitiesContext()) { var query = from _StoreProducts in Utils.DbContext.StoreProducts join _StoreCategories in Utils.DbContext.StoreCategories on _StoreProducts.CategoryID equals _StoreCategories.CategoryID where _StoreCategories.Name == PARAM1 & _StoreCategories.PortalID == Product.PortalID select new { _StoreProducts.ProductID, _StoreProducts.CategoryID, _StoreProducts.Name, _StoreProducts.Description, _StoreProducts.Published, _StoreProducts.Deleted, _StoreProducts.Price }; foreach (var i in query) { string[] array = { i.ProductID.ToString(), "IsAjax" }; string _PARAMS = String.Join(",", array); //sb.Append(@"<div style=""font-weight: bold"">"); //sb.Append(@"<a href=""#"" onclick=""makePOSTRequest('section_body', 'PROJECT=BLL&NAMESPACE=BLL.Store&CLASS=Product&METHOD=ReturnStoreProduct&PARAMS=" + _PARAMS + @"');"">"); //sb.Append(i.Name + " - " + String.Format("{0:C}", i.Price)); //sb.Append(@"</a></div><div>" + i.Description + @"</div><hr />"); sb.Append(@"<div style=""font-weight: bold"">"); sb.Append(i.Name + " - " + String.Format("{0:C}", i.Price)); sb.Append(@"</div><div>" + i.Description + @"</div><hr />"); sb.Append(@"<div data-role=""fieldcontain"">"); //sb.Append(@"<a href=""#"" data-role=""button"" data-icon=""plus"">Add to Cart</a>"); sb.Append(@"<a href=""#"" data-role=""button"" data-icon=""plus"" onclick=""makePOST('PROJECT=BLL&NAMESPACE=BLL.Store&CLASS=Product&METHOD=AddStoreProduct&PARAMS=" + _PARAMS + @"');"">"); sb.Append(i.Name); sb.Append(@"</a>"); sb.Append(@"</div>"); } } return sb.ToString(); }
/// <summary> /// Content RadTable functions /// </summary> public static Hashtable GetAnswerGroup(int EntityKey) { var values = new Hashtable(); using (EntitiesContext context = new EntitiesContext()) { var query = from q in Utils.DbContext.SurveyAnswerGroups where q.AnswerGroupID == EntityKey select new { q.AnswerGroupID, q.PortalID, q.CreateDate, q.AnswerTypeID, q.Name }; foreach (var i in query) { values["AnswerGroupID"] = i.AnswerGroupID; values["PortalID"] = i.PortalID; values["InsertDT"] = i.CreateDate; values["AnswerTypeID"] = i.AnswerTypeID; values["Name"] = i.Name; } } return values; }
public void UpdateItemPath(string path, string newName, int newParentId) { int fileID = GetItemId(path); if (fileID < 0) { return; } using (EntitiesContext context = new EntitiesContext()) { //var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID & i.PortalID == Portals.PortalID); var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID); I.Name = newName; I.ParentID = newParentId; context.SaveChanges(); } _data = null; }
protected void Page_Init(object sender, EventArgs e) { this.context = new EntitiesContext(); this.portals = new Portals(context); }
public static Hashtable Read(int EntityKey) { var values = new Hashtable(); using (EntitiesContext context = new EntitiesContext()) { var query = from q in Utils.DbContext.Contents where q.ContentID == EntityKey select new { q.ContentID, q.ContentText, q.ContentTypeID, q.IsPublished, q.IsMenu, q.Title, q.StartMethod }; foreach (var i in query) { values["ContentID"] = i.ContentID; values["ContentText"] = i.ContentText; values["ContentTypeID"] = i.ContentTypeID; values["IsPublished"] = i.IsPublished; values["IsMenu"] = i.IsMenu; values["Title"] = i.Title; values["StartMethod"] = i.StartMethod; } } return values; }
public Results(EntitiesContext context) { this.context = context; }
public static string ReadContent(string PARAMS = null) { StringBuilder sb = new StringBuilder(); string[] VALUES = null; string PARAM1 = null; if (PARAMS != null) { VALUES = PARAMS.Split(','); if (VALUES[0] != null) { PARAM1 = VALUES[0].ToString(); } } try { using (EntitiesContext context = new DAL.EntitiesContext()) { var c = context.Contents.FirstOrDefault(q => q.URL == PARAM1 & q.PortalID == Content.PortalID); if (c != null) { sb.Append(c.ContentText); } } } catch (Exception ex) { ElmahExtension.LogToElmah(ex); } return HttpUtility.HtmlDecode(sb.ToString()); }
public void ReplaceItemContent(string path, byte[] content) { int fileID = GetItemId(path); if (fileID < 0) { return; } using (EntitiesContext context = new EntitiesContext()) { //var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID & i.PortalID == Portals.PortalID); var I = context.ContentFiles.FirstOrDefault(i => i.FileID == fileID); I.FileContent = content; context.SaveChanges(); } }
public static void InsertResult(int _QuestionID, int _AnswerID, int _UserID, string _AnswerText, int _ResultID) { using (EntitiesContext context = new EntitiesContext()) { SurveyResultItem r = new SurveyResultItem { ResultID = _ResultID, QuestionID = _QuestionID, AnswerID = _AnswerID, UserID = _UserID, AnswerText = _AnswerText, PortalID = ResultItems.PortalID }; context.SurveyResultItems.AddObject(r); context.SaveChanges(); } }