public string BackgroundColor(PicName pn) { if (!pn.IsStart()) { return("bg-success"); } if (pn.IsEnd()) { return("bg-danger"); } return(""); }
private void SaveImgs() { List <string> fileList = GetFiles(); foreach (string file in fileList) { string fileName = Common.GetLastDir(file); PicName pn = new PicName(fileName); string seq = Request.Form[fileName + "_seq"]; string startDate = Request.Form[fileName + "_start"]; string endDate = Request.Form[fileName + "_end"]; string time = Request.Form[fileName + "_time"]; string delete = Request.Form[fileName + "_delete"]; string oldFilePath = Server.MapPath("./category/" + title + "/" + fileName); if (delete == "true") { if (File.Exists(oldFilePath)) { File.Delete(oldFilePath); } } else { if (string.IsNullOrEmpty(time) || !Regex.IsMatch(time, @"^[+-]?\d*$")) { time = "10"; } string type = fileName.Substring(fileName.LastIndexOf(".") + 1); string newFileName = seq + "_" + startDate + "_" + pn.Id + "_" + endDate + "_" + time + "." + type; //string newFileName = seq + "_" + + "_" + time + "." + type; string newFilePath = Server.MapPath("./category/" + title + "/" + newFileName); if (!File.Exists(newFilePath)) { Directory.Move(oldFilePath, newFilePath); } } } }
public string PrintImg() { StringBuilder result = new StringBuilder(); string fullpath = Server.MapPath(configFile); string content; if (!System.IO.File.Exists(fullpath)) { content = "default"; } else { content = System.IO.File.ReadAllText(fullpath); } string[] cat = content.Split('\n'); string categoryPath = Server.MapPath(category); System.IO.DirectoryInfo DirInfo = new System.IO.DirectoryInfo(categoryPath); System.IO.DirectoryInfo[] dirs = DirInfo.GetDirectories(); for (int i = 0; i < cat.Length; i++) { for (int j = 0; j < dirs.Length; j++) { if (dirs[j].ToString().Trim() == cat[i].ToString().Trim()) { System.IO.DirectoryInfo targetDir = new System.IO.DirectoryInfo(categoryPath + "\\" + dirs[j] .ToString().Trim()); System.IO.FileInfo[] imgs = targetDir.GetFiles(); for (int k = 0; k < imgs.Length; k++) { PicName pn = new PicName(imgs[k].Name); if (pn.IsShow() && Common.supportedFileTypes.Contains(GetFileType(imgs[k].ToString()))) //if (imgs[k].Name != "Thumbs.db") { result.Append(GetImgWrapper(dirs[j].ToString().Trim(), imgs[k].Name, imgs[k].Extension)); } } } } } if (result.ToString() == "" || content == "default") { System.IO.DirectoryInfo targetDir = new System.IO.DirectoryInfo(categoryPath + defaultPath); System.IO.FileInfo[] imgs = targetDir.GetFiles(); for (int k = 0; k < imgs.Length; k++) { PicName pn = new PicName(imgs[k].Name); //if (imgs[k].Name != "Thumbs.db") if (pn.IsShow() && Common.supportedFileTypes.Contains(GetFileType(imgs[k].ToString()))) { result.Append(GetImgWrapper("default".Trim(), imgs[k].Name, imgs[k].Extension)); } } } return(result.ToString()); }