public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int schoolId = int.Parse(context.Request["schoolId"]); BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); var books = db.Books.ToList(); var ps = db.SchoolBooks.Where(x => x.schoolId == schoolId).ToList(); foreach (var p in ps) { db.SchoolBooks.Remove(p); } foreach (var book in books) { string spon = context.Request["book" + book.id]; if (spon == "true") { db.SchoolBooks.Add(new SchoolBook { schoolId = schoolId, bookId = book.id }); } else { var r = db.SchoolBooks.Where(x => x.schoolId == schoolId && x.bookId == book.id).SingleOrDefault(); if (r != null) { db.SchoolBooks.Remove(r); } } } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id = int.Parse(context.Request["id"]); string[] collection = context.Request["collec"].Split('!'); BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); var group = db.cms_groups.Where(x => x.id == id).SingleOrDefault(); var policies = db.cms_policies.Where(x => x.groupId == id).ToList(); foreach (cms_policies pol in policies) { db.cms_policies.Remove(pol); } foreach (string val in collection) { if (val != "") { string[] vals = val.Split('|'); db.cms_policies.Add(new cms_policies() { permissionId = int.Parse(vals[1]), groupId = id, event_permitted = vals[0] }); } } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int uniteId = int.Parse(context.Request["pageId"]); HttpPostedFile uniteFile = context.Request.Files["uniteFile"]; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); string game_file = ""; if (uniteFile.ContentLength > 0) { string sfiletype = uniteFile.FileName; sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower(); game_file = uniteFile.FileName.Replace(".zip", ""); string _path = context.Server.MapPath("~/Media/Unites/" + uniteId + "/"); DirectoryInfo dir = new DirectoryInfo(_path); if (!dir.Exists) { dir.Create(); } string filepath = _path + game_file + "." + sfiletype; uniteFile.SaveAs(filepath); FileInfo fi = new FileInfo(filepath); Decompress(filepath); fi.Delete(); } db.BookUniteFiles.Add(new BookUniteFile { InteractiveFile = game_file, uniteId = uniteId }); db.SaveChanges(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); HttpPostedFile codesfile = context.Request.Files["studentsfile"]; int levelId = int.Parse(context.Request["levelsSelect"]); int schoolId = int.Parse(context.Request["pageId"]); if (codesfile.ContentLength > 0) { string sfiletype = codesfile.FileName; sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower(); string codes_file = Guid.NewGuid().ToString() + "." + sfiletype; string _path = context.Server.MapPath("~/Media"); codesfile.SaveAs(_path + "/" + codes_file); IEnumerable <ExcelStudent> students = ReadInData.GetDataReg(_path + "/" + codes_file, "Sheet1"); foreach (var row in students) { string accessCode = Get8Digits(); var student = db.Students.Add(new Student { AccessCode = accessCode, Address = row.Address, Email = row.Email, FirstName = row.FirstName, LastName = row.LastName, Phone = row.Phone, schoolId = schoolId, levelId = levelId }); } } db.SaveChanges(); context.Response.Write("Success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); int imId = int.Parse(context.Request["id"]); var row = db.Books.Where(x => x.id == imId).SingleOrDefault(); switch (context.Request["field"]) { case "thumb": row.thumb = SaveImage(context, context.Request["img"]); break; case "pdf": row.pdf = SavePdf(context, context.Request["img"]); string pdfPath = context.Server.MapPath("~/Media/") + row.pdf; PdfReader reader = new PdfReader(pdfPath); int iorder = 1; var slides = db.BookSlides.Where(x => x.bookId == row.id).ToList(); db.BookSlides.RemoveRange(slides); for (int page = 1; page <= reader.NumberOfPages; page++) { string img = LoadImage(pdfPath, page, context); db.BookSlides.Add(new BookSlide { img = img, bookId = row.id, OrderIndex = iorder }); iorder++; } break; } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpPostedFile thumb = context.Request.Files["thumb"]; string thumb_file = ""; if (thumb.ContentLength > 0) { string sfiletype1 = thumb.FileName; sfiletype1 = sfiletype1.Substring(sfiletype1.LastIndexOf('.') + 1).ToLower(); thumb_file = Guid.NewGuid().ToString() + "." + sfiletype1; string _path1 = context.Server.MapPath("~/Media"); thumb.SaveAs(_path1 + "/" + thumb_file); } BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); string title = context.Request["title"]; string artitle = context.Request["artitle"]; School school = new School { title = title, thumb = thumb_file, artitle = artitle }; school = db.Schools.Add(school); db.SaveChanges(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpFileCollection thumbs = context.Request.Files; int bookId = int.Parse(context.Request["bookId"]); BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); int iorder = 1; var lastslide = db.BookSlides.Where(x => x.bookId == bookId).OrderByDescending(x => x.OrderIndex).FirstOrDefault(); if (lastslide != null) { iorder = (int)lastslide.OrderIndex; iorder++; } for (int i = 0; i < thumbs.Count; i++) { HttpPostedFile thumb = thumbs[i]; string sfiletype = thumb.FileName; sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower(); string thumb_file = Guid.NewGuid().ToString() + "." + sfiletype; string _path = context.Server.MapPath("~/Media"); thumb.SaveAs(_path + "/" + thumb_file); db.BookSlides.Add(new BookSlide { img = thumb_file, bookId = bookId, OrderIndex = iorder }); iorder++; } db.SaveChanges(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int bookId = int.Parse(context.Request["pageId"]); HttpPostedFile thumbfile = context.Request.Files["Thumb"]; HttpPostedFile pdffile = context.Request.Files["pdf"]; HttpPostedFile gamefile = context.Request.Files["GameFile"]; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); string title = context.Request["title"]; string pdf_file = ""; if (pdffile.ContentLength > 0) { string sfiletype = pdffile.FileName; sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower(); pdf_file = Guid.NewGuid().ToString() + "." + sfiletype; string _path = context.Server.MapPath("~/Media"); pdffile.SaveAs(_path + "/" + pdf_file); } string thumb_file = ""; if (thumbfile.ContentLength > 0) { string sfiletype = thumbfile.FileName; sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower(); thumb_file = Guid.NewGuid().ToString() + "." + sfiletype; string _path = context.Server.MapPath("~/Media"); thumbfile.SaveAs(_path + "/" + thumb_file); } string game_file = ""; if (gamefile.ContentLength > 0) { string sfiletype = gamefile.FileName; sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower(); game_file = gamefile.FileName.Replace(".zip", ""); string _path = context.Server.MapPath("~/Media/Stories/" + bookId + "/"); DirectoryInfo dir = new DirectoryInfo(_path); if (!dir.Exists) { dir.Create(); } string filepath = _path + game_file + "." + sfiletype; gamefile.SaveAs(filepath); FileInfo fi = new FileInfo(filepath); Decompress(filepath); fi.Delete(); } db.BookStories.Add(new BookStory { InteractiveFile = game_file, bookId = bookId, thumb = thumb_file, title = title, pdf = pdf_file }); db.SaveChanges(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); Content content = new Content(); var contentList = db.Contents; if (contentList.Count() > 0) { content = contentList.FirstOrDefault(); content.AboutUs = context.Request["AboutUs"]; content.Description = context.Request["Description"]; content.keywords = context.Request["Keywords"]; content.Email = context.Request["Email"]; content.AddressLine = context.Request["AddressLine"]; content.Phone = context.Request["Phone"]; content.Fax = context.Request["Fax"]; content.longitude = context.Request["Longitude"]; content.latitude = context.Request["Latitude"]; content.SmtpServer = context.Request["SmtpServer"]; content.SmtpPort = context.Request["SmtpPort"]; content.IsSSL = context.Request["IsSSL"] == "on"; content.SystemEmail = context.Request["SystemEmail"]; content.SystemEmailPassword = context.Request["SystemEmailPassword"]; content.InfoEmail = context.Request["InfoEmail"]; content.SmartLearningVideo = context.Request["SmartLearningVideo"]; } else { content.AboutUs = context.Request["AboutUs"]; content.Description = context.Request["Description"]; content.keywords = context.Request["Keywords"]; content.Email = context.Request["Email"]; content.AddressLine = context.Request["AddressLine"]; content.Phone = context.Request["Phone"]; content.Fax = context.Request["Fax"]; content.longitude = context.Request["Longitude"]; content.latitude = context.Request["Latitude"]; content.SmtpServer = context.Request["SmtpServer"]; content.SmtpPort = context.Request["SmtpPort"]; content.IsSSL = context.Request["IsSSL"] == "on"; content.SystemEmail = context.Request["SystemEmail"]; content.SystemEmailPassword = context.Request["SystemEmailPassword"]; content.InfoEmail = context.Request["InfoEmail"]; content.SmartLearningVideo = context.Request["SmartLearningVideo"]; db.Contents.Add(content); } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); int imId = int.Parse(context.Request["id"]); var row = db.Schools.Where(x => x.id == imId).SingleOrDefault(); switch (context.Request["field"]) { case "thumb": row.thumb = SaveImage(context, context.Request["img"]); break; } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); int imId = int.Parse(context.Request["id"]); var row = db.BookPosters.Where(x => x.id == imId).SingleOrDefault(); switch (context.Request["field"]) { case "Img": row.thumb = SaveImage(context, context.Request["img"]); break; case "interactive": string filename = row.InteractiveFile; row.InteractiveFile = SaveZip(context, context.Request["img"], filename, row.bookId); break; } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpPostedFile thumb = context.Request.Files["thumb"]; HttpPostedFile Pdffile = context.Request.Files["pdf"]; string thumb_file = "", pdf_file = ""; if (thumb.ContentLength > 0) { string sfiletype1 = thumb.FileName; sfiletype1 = sfiletype1.Substring(sfiletype1.LastIndexOf('.') + 1).ToLower(); thumb_file = Guid.NewGuid().ToString() + "." + sfiletype1; string _path1 = context.Server.MapPath("~/Media"); thumb.SaveAs(_path1 + "/" + thumb_file); } if (Pdffile.ContentLength > 0) { string sfiletype1 = Pdffile.FileName; sfiletype1 = sfiletype1.Substring(sfiletype1.LastIndexOf('.') + 1).ToLower(); pdf_file = Guid.NewGuid().ToString() + "." + sfiletype1; string _path1 = context.Server.MapPath("~/Media"); Pdffile.SaveAs(_path1 + "/" + pdf_file); } BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); string title = context.Request["title"]; string lang = context.Request["langselect"]; bool isAvailable = context.Request["isAvailable"] == "on"; int levelId = int.Parse(context.Request["levelselect"]); int categoryId = int.Parse(context.Request["categoryselect"]); bool isSingleBook = context.Request["isSingleBook"] == "on"; string VimeoId = context.Request["VimeoId"]; Book book = new Book { title = title, thumb = thumb_file, pdf = pdf_file, isAvailable = isAvailable, lang = lang, levelId = levelId, categoryId = categoryId, isSingleBook = isSingleBook, VimeoId = VimeoId }; book = db.Books.Add(book); db.SaveChanges(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); int id = int.Parse(context.Request["id"]); int toPosition = int.Parse(context.Request["toPosition"]); int fromPosition = int.Parse(context.Request["fromPosition"]); string direction = context.Request["direction"]; string table = context.Request["table"]; switch (table) { case "Levels": if (direction == "back") { var moved = db.BooksLevels.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex++; } } else { var moved = db.BooksLevels.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex--; if (p.OrderIndex < 0) { p.OrderIndex = 0; } } } db.BooksLevels.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition; break; case "Categories": if (direction == "back") { var moved = db.Categories.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex++; } } else { var moved = db.Categories.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex--; if (p.OrderIndex < 0) { p.OrderIndex = 0; } } } db.Categories.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition; break; case "Slides": if (direction == "back") { var moved = db.BookSlides.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex++; } } else { var moved = db.BookSlides.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex--; if (p.OrderIndex < 0) { p.OrderIndex = 0; } } } db.BookSlides.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition; break; case "BookUnites": if (direction == "back") { var moved = db.BookUnites.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex++; } } else { var moved = db.BookUnites.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition)) .ToList(); foreach (var p in moved) { p.OrderIndex--; if (p.OrderIndex < 0) { p.OrderIndex = 0; } } } db.BookUnites.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition; break; } db.SaveChanges(); context.Response.Write("success"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string name = context.Request.Form["name"]; string value = context.Request.Form["value"]; int pk = int.Parse(context.Request.Form["pk"]); string success = ""; string table = context.Request.QueryString["table"]; if (table == null) { table = context.Request.Form["table"]; } BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); switch (table) { case "cms_user": var user = db.cms_user.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("username")) { user.username = value; } else if (name.Contains("cmsgroup")) { user.groupId = int.Parse(value); } else if (name.Contains("status")) { user.status = int.Parse(value); } else if (name.Contains("password")) { user.password = MD5Hash(value); } else if (name.Contains("firstname")) { user.firstname = value; } else if (name.Contains("lastname")) { user.lastname = value; } else if (name.Contains("email")) { user.email = value; } else if (name.Contains("phone")) { user.phone = value; } else if (name.Contains("address")) { user.address = value; } success = "success"; break; case "cms_groups": var group = db.cms_groups.Where(x => x.id == pk).SingleOrDefault(); group.name = value; success = "success"; break; case "Books": var project = db.Books.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("title")) { project.title = value; } else if (name.Contains("lang")) { project.lang = value; } if (name.Contains("level")) { project.levelId = int.Parse(value); } else if (name.Contains("isAvailable")) { project.isAvailable = value == "YES"; } else if (name.Contains("isSingleBook")) { project.isSingleBook = value == "YES"; } if (name.Contains("VimeoId")) { project.VimeoId = value; } success = "success"; break; case "BookUnites": var unite = db.BookUnites.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("title")) { unite.title = value; } success = "success"; break; case "Posters": var poster = db.BookPosters.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("title")) { poster.title = value; } break; case "Stories": var story = db.BookStories.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("title")) { story.title = value; } break; case "Levels": var level = db.BooksLevels.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("title")) { level.title = value; } if (name.Contains("lang")) { level.lang = value; } success = "success"; break; case "BooksCategories": var cat = db.Categories.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("title")) { cat.title = value; } success = "success"; break; case "Schools": var school = db.Schools.Where(x => x.id == pk).SingleOrDefault(); if (name.Contains("artitle")) { school.artitle = value; } if (name.Contains("entitle")) { school.title = value; } if (name.Contains("showGame")) { school.showGame = value == "YES"; } success = "success"; break; case "Students": var student = db.Students.Where(x => x.id == pk).SingleOrDefault(); student.levelId = int.Parse(value); break; } db.SaveChanges(); context.Response.Write(success); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string table = context.Request.Form["table"]; string Rows = context.Request.Form["Rows"]; string[] split = Rows.Split('|'); string success = ""; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); int lastOrderId = 1; switch (table) { case "cms_user": db.cms_user.Add(new cms_user() { username = split[0], password = MD5Hash(split[1]), groupId = int.Parse(split[2]), status = int.Parse(split[3]), firstname = split[4], lastname = split[5], phone = split[6], email = split[7], address = split[8] }); success = "success"; break; case "cms_groups": db.cms_groups.Add(new cms_groups() { name = split[0] }); success = "success"; break; case "Levels": var orderId = db.BooksLevels.OrderByDescending(x => x.OrderIndex).FirstOrDefault(); if (orderId != null) { lastOrderId = (int)orderId.OrderIndex + 1; } db.BooksLevels.Add(new BooksLevel() { title = split[0], lang = split[1], OrderIndex = lastOrderId }); success = "success"; break; case "BooksCategories": var catorderId = db.Categories.OrderByDescending(x => x.OrderIndex).FirstOrDefault(); if (catorderId != null) { lastOrderId = (int)catorderId.OrderIndex + 1; } db.Categories.Add(new Category() { title = split[0], OrderIndex = lastOrderId }); success = "success"; break; case "BookUnites": var lastunite = db.BookUnites.OrderByDescending(x => x.OrderIndex).FirstOrDefault(); if (lastunite != null) { lastOrderId = (int)lastunite.OrderIndex + 1; } db.BookUnites.Add(new BookUnite { title = split[0], bookId = int.Parse(split[1]), OrderIndex = lastOrderId }); break; case "IPs": string val = split[0]; BlockIP(val); break; } db.SaveChanges(); context.Response.Write(success); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string table = context.Request.Form["table"]; string ips = context.Request.Form["ips"]; int tableId = int.Parse(context.Request.Form["tableId"]); string key = context.Request["key"]; BrandsMktgBooksEntities db = new BrandsMktgBooksEntities(); string success = ""; switch (table) { case "cms_user": cms_user user = db.cms_user.Where(x => x.id == tableId).SingleOrDefault(); db.cms_user.Remove(user); success = "success"; break; case "cms_groups": cms_groups group = db.cms_groups.Where(x => x.id == tableId).SingleOrDefault(); db.cms_groups.Remove(group); success = "success"; break; case "Slides": BookSlide slide = db.BookSlides.Where(x => x.id == tableId).SingleOrDefault(); db.BookSlides.Remove(slide); success = "success"; try { File.Delete(context.Server.MapPath("~/Media/" + slide.img)); } catch { } break; case "BookUnites": BookUnite bunite = db.BookUnites.Where(x => x.id == tableId).SingleOrDefault(); db.BookUnites.Remove(bunite); success = "success"; break; case "BookUniteFiles": BookUniteFile unitefile = db.BookUniteFiles.Where(x => x.id == tableId).SingleOrDefault(); db.BookUniteFiles.Remove(unitefile); success = "success"; break; case "Books": Book b = db.Books.Where(x => x.id == tableId).SingleOrDefault(); db.Books.Remove(b); success = "success"; try { File.Delete(context.Server.MapPath("~/Media/" + b.thumb)); File.Delete(context.Server.MapPath("~/Media/" + b.pdf)); } catch { } break; case "Levels": BooksLevel level = db.BooksLevels.Where(x => x.id == tableId).SingleOrDefault(); db.BooksLevels.Remove(level); success = "success"; break; case "BooksCategories": Category cat = db.Categories.Where(x => x.id == tableId).SingleOrDefault(); db.Categories.Remove(cat); success = "success"; break; case "Schools": School school = db.Schools.Where(x => x.id == tableId).SingleOrDefault(); db.Schools.Remove(school); success = "success"; try { File.Delete(context.Server.MapPath("~/Media/" + school.thumb)); } catch { } break; case "Posters": BookPoster game = db.BookPosters.Where(x => x.id == tableId).SingleOrDefault(); db.BookPosters.Remove(game); try { Directory.Delete(context.Server.MapPath("~/Media/Games/" + game.bookId + "/" + game.InteractiveFile)); File.Delete(context.Server.MapPath("~/Media/" + game.thumb)); } catch { } success = "success"; break; case "Stories": BookStory story = db.BookStories.Where(x => x.id == tableId).SingleOrDefault(); db.BookStories.Remove(story); try { Directory.Delete(context.Server.MapPath("~/Media/Games/" + story.bookId + "/" + story.InteractiveFile)); File.Delete(context.Server.MapPath("~/Media/" + story.thumb)); File.Delete(context.Server.MapPath("~/Media/" + story.pdf)); } catch { } success = "success"; break; case "IPs": AllowIP(ips); break; case "Sessions": SessionUser.Remove(key); break; } db.SaveChanges(); context.Response.Write(success); }