public ActionResult Adm(string id) { var list = new List<DayStory>(); var dirs = new DirectoryInfo(_root); var fldrs = dirs.GetDirectories(); foreach (var dirInfo in fldrs) { var d = new DayStory().GetAllDays(dirInfo.Name); list.AddRange(d); } return View(list); }
public ActionResult Day(BasePath b) { var d = new DayStory(); if (b.Date == null) { d.Day = DateTime.Now.ToShortDateString(); //d.Category = "main"; } else { d = DayStory.GetSingleDay(b); } return View("Day", d); }
public ActionResult SaveDay(FormCollection collection) { var d = new DayStory {Day = collection[0], Header = collection[1], Text = collection[3], Category = collection[2]}; try { DayStory.Save(d); return Redirect("/Home/UploadEdit/" + d.Category + "/" + d.Day); } catch(Exception ex) { throw ex; } }
public static void Save(DayStory d) { if (d.Category.Length == 0) d.Category = "main"; var sPath = ConfigurationManager.AppSettings["UploadUrl"] + d.Category + "\\" + d.Day; Directory.CreateDirectory(sPath); Directory.CreateDirectory(sPath+"\\thumbnails"); TextFile.CreateFile(sPath + "\\main.txt"); TextFile.AppendToFile(sPath + "\\main.txt", d.Text); TextFile.CreateFile(sPath + "\\header.txt"); TextFile.AppendToFile(sPath + "\\header.txt", d.Header); TextFile.CreateFile(sPath + "\\category.txt"); TextFile.AppendToFile(sPath + "\\category.txt", d.Category); }
public static void Save(DayStory d) { if (d.Category.Length == 0) { d.Category = "main"; } var sPath = ConfigurationManager.AppSettings["UploadUrl"] + d.Category + "\\" + d.Day; Directory.CreateDirectory(sPath); Directory.CreateDirectory(sPath + "\\thumbnails"); TextFile.CreateFile(sPath + "\\main.txt"); TextFile.AppendToFile(sPath + "\\main.txt", d.Text); TextFile.CreateFile(sPath + "\\header.txt"); TextFile.AppendToFile(sPath + "\\header.txt", d.Header); TextFile.CreateFile(sPath + "\\category.txt"); TextFile.AppendToFile(sPath + "\\category.txt", d.Category); }
//toDo: Exclude data to ext ilayer and dal-class public static DayStory GetSingleDay(BasePath b) { try { var d = new DayStory(); var date = b.Date; d.Day = date; string sPath = String.Concat(b.Path, b.Category, "\\", b.Date + "\\"); d.Text = TextFile.ReadFileWithoutEncoding(sPath + "main.txt"); d.Header = TextFile.ReadFileWithoutEncoding(sPath + "header.txt"); d.Category = TextFile.ReadFileWithoutEncoding(sPath + "category.txt"); d.Comments = Reply.GetReplies(sPath); if (Image.GetAllImages(b).Count > 0) { d.Img = Image.GetAllImages(b)[0].Url; d.Images = Image.GetAllImages(b); } return d; //diaryText = diaryText.Replace("\r\n", "<br>").Replace("\r", "<br>").Replace("\n", "<br>"); } catch (Exception ex) { return null; //throw ex; } }
//toDo: Exclude data to ext ilayer and dal-class public static DayStory GetSingleDay(BasePath b) { try { var d = new DayStory(); var date = b.Date; d.Day = date; string sPath = String.Concat(b.Path, b.Category, "\\", b.Date + "\\"); d.Text = TextFile.ReadFileWithoutEncoding(sPath + "main.txt"); d.Header = TextFile.ReadFileWithoutEncoding(sPath + "header.txt"); d.Category = TextFile.ReadFileWithoutEncoding(sPath + "category.txt"); d.Comments = Reply.GetReplies(sPath); if (Image.GetAllImages(b).Count > 0) { d.Img = Image.GetAllImages(b)[0].Url; d.Images = Image.GetAllImages(b); } return(d); //diaryText = diaryText.Replace("\r\n", "<br>").Replace("\r", "<br>").Replace("\n", "<br>"); } catch (Exception ex) { return(null); //throw ex; } }
public ActionResult Upload(DayStory d) { return View("Upload", d); }