Example #1
0
 public ActionResult Details(BasePath b)
 {
     if (b.Date != null) {
         return View(DayStory.GetSingleDay(b));
     }
     return null;
 }
Example #2
0
        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);
        }
Example #3
0
        public static List<Image> GetAllImages(BasePath b)
        {
            var l = new List<Image>();
            var dir = new DirectoryInfo(String.Concat(b.Path, b.Category, "\\", b.Date + "\\"));
            foreach (var fileInfo in dir.GetFiles())
            {
                if (fileInfo.Extension.ToLower() != ".jpg") continue;

                var imageComment = TextFile.ReadFileWithoutEncoding(fileInfo.FullName + ".txt");

                var img = new Image
                          {
                              Name = fileInfo.Name.Replace(".","_____"),
                                  Url = "/Upload/" + b.Category + "/" + b.Date + "/" + fileInfo.Name,
                                  Thumb = "/Upload/" + b.Category + "/" + b.Date + "/thumbnails/" + fileInfo.Name,
                                  Comment = imageComment
                              };
                l.Add(img);
            }
            return l;
        }
Example #4
0
 //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;
     }
 }
Example #5
0
 public ActionResult UploadEdit(string category, string id)
 {
     var b = new BasePath() { Date = id, Category = category};
     var d = DayStory.GetSingleDay(b);
     //var day = DayStory.GetSingleDay(new BasePath(){Category = d.Category, Date = d.Day, Path = ConfigurationManager.AppSettings["UploadUrl"]}) ?? new DayStory {Day = d.Day};
     return View("Upload", d);
 }
Example #6
0
 public ActionResult DayEdit(string category, string id)
 {
     var b = new BasePath(){ Category = category, Date = id};
     var d = DayStory.GetSingleDay(b);
     return View("Day", d);
 }
Example #7
0
 public ActionResult Day(BasePath b)
 {
     var d = DayStory.GetSingleDay(b) ?? new DayStory {Day = b.Date};
         return View("Day", d);
 }
Example #8
0
        public List<DayStory> GetAllDays(string cat)
        {
            var sPath = ConfigurationManager.AppSettings["UploadUrl"]  + cat + "\\";

            var stories = new List<DayStory>();
            var dirs = new DirectoryInfo(sPath);
            var comparer = new myReverserClass();
            DirectoryInfo[] fldrs = dirs.GetDirectories();
            Array.Sort(fldrs, comparer);
            foreach (var dirInfo in fldrs) {
                var b = new BasePath(){Date = dirInfo.Name, Category = cat};
                var d = GetSingleDay(b);
                    stories.Add(d);
            }
            return stories;
        }
Example #9
0
 public ActionResult Refresh(BasePath b)
 {
     var d = DayStory.GetSingleDay(b);
        return View("Upload", d);
 }