parent
66cde3a022
commit
37f2321a4b
|
|
@ -538,80 +538,6 @@ namespace NP.Base
|
|||
return null;
|
||||
}
|
||||
}
|
||||
protected long? SetFileToEstimation(IList<System.Web.HttpPostedFileBase> upFiles, long fgno, String tablename, String columnname, int fseq = 1, String FGKey = "XX", bool iscontents = false, bool issubject = false, int cmno = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fcnt = upFiles.Count;
|
||||
if (fcnt < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//만약 다중파일의 두 번째부터 이후의 파일들의 경우 파일그룹번호가 0 이면서 FGKey가 동일한 것이 DB에 있으면 그 FGNo를 사용한다.
|
||||
if (fgno < 1 && fseq > 1 && FGKey != "")
|
||||
{
|
||||
var fg = Dao.Get<NP.Model.File>("sys.file.getfgnobyfgkey", FGKey).FirstOrDefault();
|
||||
fgno = fg == null ? 0 : fg.fgno;
|
||||
}
|
||||
var finfos = new NP.Model.File() { fgno = fgno, tablename = tablename, columnname = columnname, uno = SUserInfo.UserNo, uip = GetUserIP() };
|
||||
finfos.Files = new List<NP.Model.File>();
|
||||
var _month = DateTime.Now.ToString("yyyyMM");
|
||||
if (issubject)
|
||||
{
|
||||
if (!System.IO.Directory.Exists(Server.MapPath(string.Format(@"{0}\{1}", NP.Model.Base.Subjects, cmno))))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(Server.MapPath(string.Format(@"{0}\{1}", NP.Model.Base.Subjects, cmno)));
|
||||
}
|
||||
}
|
||||
else if (!System.IO.Directory.Exists(Server.MapPath(string.Format(@"{0}\{1}\{2}", iscontents ? NP.Model.Base.Contents : NP.Model.Base.Files, _month, tablename))))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(Server.MapPath(string.Format(@"{0}\{1}\{2}", iscontents ? NP.Model.Base.Contents : NP.Model.Base.Files, _month, tablename)));
|
||||
}
|
||||
int filelength = 0;
|
||||
for (int i = 0; i < fcnt; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(upFiles[i].FileName))
|
||||
{
|
||||
filelength += upFiles[i].ContentLength;
|
||||
string fileExt = System.IO.Path.GetExtension(upFiles[i].FileName.Split('\\').Last());
|
||||
string fileFullPath = issubject ? string.Format(@"\{0}\{5}_{1}_{2}_{3}{4}", cmno, SUserInfo.UserNo, DateTime.Now.ToString("yyyyMMddHHmmssfff"), i, fileExt, string.Format("{0:yyyyMMdd}", DateTime.Now)) : string.Format(@"\{0}\{1}\{5}_{2}_{3}{4}", _month, tablename, DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + SUserInfo.UserNo.ToString(), i, fileExt, string.Format("{0:yyyyMMdd}", DateTime.Now));
|
||||
//fileFullPath = string.Format("{0:yyyyMMdd}", DateTime.Now) + fileFullPath;
|
||||
string fileFullPathStr = (issubject ? NP.Model.Base.Subjects : iscontents ? NP.Model.Base.Contents : NP.Model.Base.Files) + "\\"+ fileFullPath;
|
||||
fileFullPathStr = fileFullPathStr.Replace("\\\\", "\\");
|
||||
|
||||
upFiles[i].SaveAs(Server.MapPath(fileFullPathStr));
|
||||
finfos.Files.Add(new Model.File()
|
||||
{
|
||||
orgname = upFiles[i].FileName.Split('\\').Last(),
|
||||
fileurl = fileFullPath.Replace("\\", "/"),
|
||||
filesize = upFiles[i].ContentLength,
|
||||
extension = fileExt.Replace(".", "")
|
||||
});
|
||||
}
|
||||
}
|
||||
if (finfos.Files.Count() > 0)
|
||||
{
|
||||
if (finfos.fgno < 1)
|
||||
{
|
||||
Dao.Insert<NP.Model.File>("sys.filegroup.insert", finfos);
|
||||
}
|
||||
if (finfos.fgno > 0)
|
||||
{
|
||||
if (Dao.Save("sys.filegroup.save", finfos) > 0)
|
||||
{
|
||||
return finfos.fgno;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Logger.TryError(ex.Message, ex);
|
||||
SetError(ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
protected long SetFileSingle(System.Web.HttpPostedFileBase upFile, long fgno, String tablename, int fseq, String FGKey)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace NP.Base.Controllers
|
|||
d.userno = SUserInfo.UserNo;
|
||||
if (Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).Count() > 0)
|
||||
{
|
||||
d.fgno = SetFileToEstimation(Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).ToList(), d.fgno ?? 0, "lectsd", "fgno", 1, "XX", false, true, d.cmno);
|
||||
d.fgno = SetFile(Request.Files.GetMultiple("file1").Where(w => !string.IsNullOrEmpty(w.FileName)).ToList(), d.fgno ?? 0, "lectsd", "fgno", 1, "XX", false, true, d.cmno);
|
||||
d.fgno = d.fgno == 0 ? (Int64?)null : d.fgno;
|
||||
}
|
||||
return JsonOK(Dao.Save("cr.lectsd.save", d));
|
||||
|
|
|
|||
Loading…
Reference in New Issue