//----< GET api/File - get list of available files >--------------- public IEnumerable <string> Get(string level) { // available files if (level == "collage") { Models.StoryCollection clg = new Models.StoryCollection(); string[] files = new string[clg.CollectionList.Count()]; int i = 0; foreach (var colg in clg.CollectionList) { string id = colg.id.ToString(); string name = colg.collageName; files[i] = name + "_" + id; i++; } return(files); } else { Models.Collage collage = new Models.Collage(); string[] files = new string[collage.storyList.Count()]; int i = 0; foreach (var story in collage.storyList) { string id = story.id.ToString(); string name = story.storyCaption; files[i] = name + "_" + id; i++; } return(files); } }
//----< GET api/File - get list of available files >--------------- public IEnumerable<string> Get(string level) { // available files if(level == "collage"){ Models.StoryCollection clg = new Models.StoryCollection(); string[] files = new string[clg.CollectionList.Count()]; int i = 0; foreach (var colg in clg.CollectionList) { string id = colg.id.ToString(); string name = colg.collageName; files[i] = name+"_"+id ; i++; } return files; } else { Models.Collage collage = new Models.Collage(); string[] files = new string[collage.storyList.Count()]; int i = 0; foreach (var story in collage.storyList) { string id = story.id.ToString(); string name = story.storyCaption; files[i] = name + "_" + id; i++; } return files; } }
public ActionResult Create(FormCollection collection) { try { Models.StoryCollection StoryCollection = new Models.StoryCollection(); Models.Collage collage = new Models.Collage(); string path = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument doc = XDocument.Load(path); if (!doc.Element("collages").Elements("collage").Any()) { collage.id = 1; } else { collage.id = (int)(from S in doc.Descendants("collage") orderby(int) S.Element("id") descending select(int) S.Element("id")).FirstOrDefault() + 1; } collage.collageName = collection["CollageName"]; string checkResp = collection["checkResp"]; collage.storyId = checkResp.Split(',').ToList(); StoryCollection.CollectionList.Add(collage); StoryCollection.Create(collage); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { try { Models.StoryCollection StoryCollection = new Models.StoryCollection(); Models.Collage collage = new Models.Collage(); string path = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument doc = XDocument.Load(path); if(!doc.Element("collages").Elements("collage").Any()) { collage.id = 1; } else { collage.id = (int)(from S in doc.Descendants("collage") orderby (int)S.Element("id") descending select (int)S.Element("id")).FirstOrDefault()+1; } collage.collageName = collection["CollageName"]; string checkResp = collection["checkResp"]; collage.storyId = checkResp.Split(',').ToList(); StoryCollection.CollectionList.Add(collage); StoryCollection.Create(collage); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Delete(int id) { try { ViewBag.id = collageId; Models.Collage collage = new Models.Collage(); foreach (Models.Story story in collage.storyList) { if (story.id == id) { return View(story); } } return RedirectToAction("Index" + "/" + collageId); } catch { return RedirectToAction("Index" + "/" + collageId); } }
public ActionResult Delete(int id) { try { ViewBag.id = collageId; Models.Collage collage = new Models.Collage(); foreach (Models.Story story in collage.storyList) { if (story.id == id) { return(View(story)); } } return(RedirectToAction("Index" + "/" + collageId)); } catch { return(RedirectToAction("Index" + "/" + collageId)); } }
public ActionResult Create(FormCollection collection) { Models.Collage collage = new Models.Collage(); Models.Story story = new Models.Story(); if (!doc.Element("collages").Elements("collage").Elements("story").Any()) { story.id = 0; } else { story.id = (int)(from S in doc.Descendants("story") orderby(int) S.Element("id") descending select(int) S.Element("id")).FirstOrDefault() + 1; } story.storyCaption = collection["StoryCaption"]; story.storyTime = collection["StoryTime"]; story.storyOrder = collection["StoryOrder"]; collage.Create(collageId, story); return(RedirectToAction("Index" + "/" + collageId)); }
public ActionResult Create(FormCollection collection) { Models.Collage collage = new Models.Collage(); Models.Story story = new Models.Story(); if (!doc.Element("collages").Elements("collage").Elements("story").Any()) { story.id = 0; } else { story.id = (int)(from S in doc.Descendants("story") orderby (int)S.Element("id") descending select (int)S.Element("id")).FirstOrDefault() + 1; } story.storyCaption = collection["StoryCaption"]; story.storyTime = collection["StoryTime"]; story.storyOrder = collection["StoryOrder"]; collage.Create(collageId, story); return RedirectToAction("Index"+"/"+collageId); }
public ActionResult Edit(int id, FormCollection collection) { try { ViewBag.id = collageId; Models.Collage collage = new Models.Collage(); foreach (Models.Story story in collage.storyList) { if (story.id == id) { story.storyCaption = collection["StoryCaption"]; story.storyTime = collection["StoryTime"]; story.storyOrder = collection["StoryOrder"]; collage.Edit(collageId, story); break; } } return(RedirectToAction("Index" + "/" + collageId)); } catch { return(View()); } }
public ActionResult Index(int id) { collageId = id; ViewBag.id = id; Models.Collage all = new Models.Collage(); List<Models.Story> storyList = new List<Models.Story>(); if (id == 0) { return View(all.storyList); } else { Models.Archive archive = new Models.Archive(); List<int> styId = new List<int>(); foreach (int a in archive.archiveList) { string collection = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument docu = XDocument.Load(collection); var cos = from s in doc.Elements("collages").Elements("collage") select s; foreach (var co in cos) { if (co.Element("id").Value == a.ToString()) { var ids = from s in co.Elements("storyId") select s; foreach (var sid in ids) { styId.Add(Int32.Parse(sid.Value)); } } } } var clgs = from collage in collection1.Element("collages") .Elements("collage") select collage; foreach (var clg in clgs) { if (clg.Element("id").Value == id.ToString()) { ViewBag.collageName = clg.Element("collageName").Value; var styids = from story in clg.Elements("storyId") select story; ViewBag.storyId = styids.First().Value; var s_in_c = from sty in doc.Element("collages").Elements("collage").Elements("story") select sty; foreach (var styid in styids) { foreach (var elem in s_in_c) { if (styid.Value == elem.Element("id").Value) { Models.Story c = new Models.Story(); c.id = Int32.Parse(elem.Element("id").Value); c.storyCaption = elem.Element("storyCaption").Value; c.storyTime = elem.Element("storyTime").Value; c.storyOrder = elem.Element("storyOrder").Value; storyList.Add(c); foreach (int i in styId) { if (i == c.id) { storyList.Remove(c); } } } } } return View(storyList); } } } return View(); }
public ActionResult Edit(int id, FormCollection collection) { try { ViewBag.id = collageId; Models.Collage collage = new Models.Collage(); foreach (Models.Story story in collage.storyList) { if (story.id == id) { story.storyCaption = collection["StoryCaption"]; story.storyTime = collection["StoryTime"]; story.storyOrder = collection["StoryOrder"]; collage.Edit(collageId, story); break; } } return RedirectToAction("Index" + "/" + collageId); } catch { return View(); } }
public ActionResult showImgView(int id, int? clgId) { ViewBag.storyId = id; storyId = id; //????? ViewBag.collageId = clgId; collageId = clgId ?? default(int); List<Models.StoryBlock> blockList = new List<Models.StoryBlock>(); //get the list of stories in each collage string pathc = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\Collages.xml"); XDocument doc = XDocument.Load(pathc); string paths = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument collection = XDocument.Load(paths); Models.Collage c = new Models.Collage(); List<Models.Story> stories = new List<Models.Story>(); if (collageId == 0) //all stories in collage 0 { stories = c.storyList; } else { // choose stories in other collage and add to List List<Models.Story> storyList = new List<Models.Story>(); var clgs = from collage in collection.Element("collages") .Elements("collage") select collage; foreach (var clg in clgs) { if (clg.Element("id").Value == collageId.ToString()) { ViewBag.collageName = clg.Element("collageName").Value; var styids = from story in clg.Elements("storyId") select story; var s_in_c = from sty in doc.Element("collages").Elements("collage").Elements("story") select sty; foreach (var styid in styids) { foreach (var elem in s_in_c) { if (styid.Value == elem.Element("id").Value) { Models.Story st = new Models.Story(); st.id = Int32.Parse(elem.Element("id").Value); st.storyCaption = elem.Element("storyCaption").Value; st.storyTime = elem.Element("storyTime").Value; st.storyOrder = elem.Element("storyOrder").Value; storyList.Add(st); } } } stories = storyList; } } } //get the id of each story in collage int[] stor = new int[stories.Count()]; int i = 0; foreach (Models.Story story in stories) { stor[i] = story.id; i++; } if (id == stor[stor.Count() - 1]) { ViewBag.run = stor[0]; } else { for (int j = 0; j < stories.Count(); j++) { if (id == stor[j]) { ViewBag.run = stor[j + 1]; } } } //get information of each block in story var stys = from story in doc.Element("collages") .Elements("collage").Elements("story") orderby (int)story.Element("storyOrder") select story; foreach (var sty in stys) { if (sty.Element("id").Value == id.ToString()) { ViewBag.story = sty.Element("storyCaption").Value; ViewBag.storyTime = sty.Element("storyTime").Value + "000"; var blk = from block in sty.Elements("block") orderby (int)block.Element("bolckOrder") select block; foreach (var elem in blk) { Models.StoryBlock cs = new Models.StoryBlock(); cs.id = Int32.Parse(elem.Element("id").Value); cs.blockCaption = elem.Element("blockCaption").Value; cs.blockContent = elem.Element("blockContent").Value; cs.bolckOrder = elem.Element("bolckOrder").Value; if (elem.Element("imgPath") != null) { cs.imgPath = elem.Element("imgPath").Value; } blockList.Add(cs); } return View(blockList); } } return View(); }
// // GET: /PrepDownload/ public FilePathResult Index(int collageId, string api = "") { string path = System.Web.HttpContext.Current.Server.MapPath("~\\Img\\"); string pathc = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\Collages.xml"); XDocument doc = XDocument.Load(pathc); string paths = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument collection = XDocument.Load(paths); Models.Collage c = new Models.Collage(); stories = new List <Models.Story>(); if (collageId == 0) //all stories { stories = c.storyList; } else { List <Models.Story> storyList = new List <Models.Story>(); // choose stories in collage and add to List var clgs = from collage in collection.Element("collages") .Elements("collage") select collage; foreach (var clg in clgs) { if (clg.Element("id").Value == collageId.ToString()) { ViewBag.collageName = clg.Element("collageName").Value; var styids = from story in clg.Elements("storyId") select story; var s_in_c = from sty in doc.Element("collages").Elements("collage").Elements("story") select sty; foreach (var styid in styids) { foreach (var elem in s_in_c) { if (styid.Value == elem.Element("id").Value) { Models.Story st = new Models.Story(); st.id = Int32.Parse(elem.Element("id").Value); st.storyCaption = elem.Element("storyCaption").Value; st.storyTime = elem.Element("storyTime").Value; st.storyOrder = elem.Element("storyOrder").Value; storyList.Add(st); } } } stories = storyList; } } } List <string> zipFiles = new List <string>(); foreach (Models.Story story in stories) { string htmlcontent = htmlBuilder(story); using (FileStream fs = new FileStream(path + story.id + "\\" + story.storyCaption + ".html", FileMode.Create)) { using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8)) { w.WriteLine(htmlcontent); } } string storyFolder = path + story.id; DirectoryInfo dir = new DirectoryInfo(storyFolder); foreach (FileInfo f in dir.GetFiles()) { zipFiles.Add(f.FullName); } } if (api == "api") { FileZipper.ZipFiles(zipFiles.ToArray(), path + "collage\\" + collageId + ".zip"); return(null); } else if (api == "archive") { FileZipper.ZipFiles(zipFiles.ToArray(), path + "archive\\" + collageId + ".zip"); return(Archive(collageId)); } else { FileZipper.ZipFiles(zipFiles.ToArray(), path + "collage\\" + collageId + ".zip"); return(Download(collageId)); } }
public ActionResult showImgView(int id, int?clgId) { ViewBag.storyId = id; storyId = id; //????? ViewBag.collageId = clgId; collageId = clgId ?? default(int); List <Models.StoryBlock> blockList = new List <Models.StoryBlock>(); //get the list of stories in each collage string pathc = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\Collages.xml"); XDocument doc = XDocument.Load(pathc); string paths = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument collection = XDocument.Load(paths); Models.Collage c = new Models.Collage(); List <Models.Story> stories = new List <Models.Story>(); if (collageId == 0) //all stories in collage 0 { stories = c.storyList; } else { // choose stories in other collage and add to List List <Models.Story> storyList = new List <Models.Story>(); var clgs = from collage in collection.Element("collages") .Elements("collage") select collage; foreach (var clg in clgs) { if (clg.Element("id").Value == collageId.ToString()) { ViewBag.collageName = clg.Element("collageName").Value; var styids = from story in clg.Elements("storyId") select story; var s_in_c = from sty in doc.Element("collages").Elements("collage").Elements("story") select sty; foreach (var styid in styids) { foreach (var elem in s_in_c) { if (styid.Value == elem.Element("id").Value) { Models.Story st = new Models.Story(); st.id = Int32.Parse(elem.Element("id").Value); st.storyCaption = elem.Element("storyCaption").Value; st.storyTime = elem.Element("storyTime").Value; st.storyOrder = elem.Element("storyOrder").Value; storyList.Add(st); } } } stories = storyList; } } } //get the id of each story in collage int[] stor = new int[stories.Count()]; int i = 0; foreach (Models.Story story in stories) { stor[i] = story.id; i++; } if (id == stor[stor.Count() - 1]) { ViewBag.run = stor[0]; } else { for (int j = 0; j < stories.Count(); j++) { if (id == stor[j]) { ViewBag.run = stor[j + 1]; } } } //get information of each block in story var stys = from story in doc.Element("collages") .Elements("collage").Elements("story") orderby(int) story.Element("storyOrder") select story; foreach (var sty in stys) { if (sty.Element("id").Value == id.ToString()) { ViewBag.story = sty.Element("storyCaption").Value; ViewBag.storyTime = sty.Element("storyTime").Value + "000"; var blk = from block in sty.Elements("block") orderby(int) block.Element("bolckOrder") select block; foreach (var elem in blk) { Models.StoryBlock cs = new Models.StoryBlock(); cs.id = Int32.Parse(elem.Element("id").Value); cs.blockCaption = elem.Element("blockCaption").Value; cs.blockContent = elem.Element("blockContent").Value; cs.bolckOrder = elem.Element("bolckOrder").Value; if (elem.Element("imgPath") != null) { cs.imgPath = elem.Element("imgPath").Value; } blockList.Add(cs); } return(View(blockList)); } } return(View()); }
// // GET: /PrepDownload/ public FilePathResult Index(int collageId, string api="") { string path = System.Web.HttpContext.Current.Server.MapPath("~\\Img\\"); string pathc = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\Collages.xml"); XDocument doc = XDocument.Load(pathc); string paths = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument collection = XDocument.Load(paths); Models.Collage c = new Models.Collage(); stories = new List<Models.Story>(); if (collageId == 0) //all stories { stories = c.storyList; } else { List<Models.Story> storyList = new List<Models.Story>(); // choose stories in collage and add to List var clgs = from collage in collection.Element("collages") .Elements("collage") select collage; foreach (var clg in clgs) { if (clg.Element("id").Value == collageId.ToString()) { ViewBag.collageName = clg.Element("collageName").Value; var styids = from story in clg.Elements("storyId") select story; var s_in_c = from sty in doc.Element("collages").Elements("collage").Elements("story") select sty; foreach (var styid in styids) { foreach (var elem in s_in_c) { if (styid.Value == elem.Element("id").Value) { Models.Story st = new Models.Story(); st.id = Int32.Parse(elem.Element("id").Value); st.storyCaption = elem.Element("storyCaption").Value; st.storyTime = elem.Element("storyTime").Value; st.storyOrder = elem.Element("storyOrder").Value; storyList.Add(st); } } } stories = storyList; } } } List<string> zipFiles = new List<string>(); foreach (Models.Story story in stories) { string htmlcontent = htmlBuilder(story); using (FileStream fs = new FileStream(path+story.id+"\\"+story.storyCaption+".html", FileMode.Create)) { using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8)) { w.WriteLine(htmlcontent); } } string storyFolder = path + story.id; DirectoryInfo dir = new DirectoryInfo(storyFolder); foreach (FileInfo f in dir.GetFiles()) { zipFiles.Add(f.FullName); } } if (api == "api") { FileZipper.ZipFiles(zipFiles.ToArray(), path + "collage\\" + collageId + ".zip"); return null; } else if (api == "archive") { FileZipper.ZipFiles(zipFiles.ToArray(), path + "archive\\" + collageId + ".zip"); return Archive(collageId); } else { FileZipper.ZipFiles(zipFiles.ToArray(), path + "collage\\" + collageId + ".zip"); return Download(collageId); } }
public ActionResult Create(Models.Collage collage) { return(View(collage)); }
public ActionResult Index(int id) { collageId = id; ViewBag.id = id; Models.Collage all = new Models.Collage(); List <Models.Story> storyList = new List <Models.Story>(); if (id == 0) { return(View(all.storyList)); } else { Models.Archive archive = new Models.Archive(); List <int> styId = new List <int>(); foreach (int a in archive.archiveList) { string collection = System.Web.HttpContext.Current.Server.MapPath("~\\App_Data\\StoryCollection.xml"); XDocument docu = XDocument.Load(collection); var cos = from s in doc.Elements("collages").Elements("collage") select s; foreach (var co in cos) { if (co.Element("id").Value == a.ToString()) { var ids = from s in co.Elements("storyId") select s; foreach (var sid in ids) { styId.Add(Int32.Parse(sid.Value)); } } } } var clgs = from collage in collection1.Element("collages") .Elements("collage") select collage; foreach (var clg in clgs) { if (clg.Element("id").Value == id.ToString()) { ViewBag.collageName = clg.Element("collageName").Value; var styids = from story in clg.Elements("storyId") select story; ViewBag.storyId = styids.First().Value; var s_in_c = from sty in doc.Element("collages").Elements("collage").Elements("story") select sty; foreach (var styid in styids) { foreach (var elem in s_in_c) { if (styid.Value == elem.Element("id").Value) { Models.Story c = new Models.Story(); c.id = Int32.Parse(elem.Element("id").Value); c.storyCaption = elem.Element("storyCaption").Value; c.storyTime = elem.Element("storyTime").Value; c.storyOrder = elem.Element("storyOrder").Value; storyList.Add(c); foreach (int i in styId) { if (i == c.id) { storyList.Remove(c); } } } } } return(View(storyList)); } } } return(View()); }