private void UploadDocument(string fileNameLocal, int idDocument) { if (!string.IsNullOrEmpty(fileNameLocal)) { var arrDocument = fileNameLocal.Split(','); foreach (var item in arrDocument) { var arrDocumentChild = item.Split(':'); var folder = DateTime.Now.Year + "\\" + DateTime.Now.Month + "\\" + DateTime.Now.Day + "\\"; var folderinsert = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/"; var urlFolder = ConfigData.DocumentFolder + folder; if (!Directory.Exists(urlFolder)) { Directory.CreateDirectory(urlFolder); } if (arrDocumentChild.Length > 1) { var fileLocal = arrDocumentChild[0].Split('.'); var fileName = FDIUtils.Slug(fileLocal[0]) + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + fileLocal[1]; var fileTemp = FDIUtils.Slug(fileLocal[0]) + "." + fileLocal[1]; System.IO.File.Copy(ConfigData.TempFolder + fileTemp, ConfigData.DocumentFolder + folder + fileName); var documentFile = new DocumentFile { Folder = folderinsert, FileUrl = fileName, DateCreated = DateTime.Now, FileSize = Convert.ToInt32(arrDocumentChild[1]), TypeFile = fileLocal[1], Status = true, }; var documentFilesDa = new DocumentFilesDA(); documentFile.Name = fileName; documentFilesDa.Add(documentFile); documentFilesDa.Save(); } } } }
public DocumentController() { _da = new DocumentsDA("#"); _categoryDa = new CategoryDA("#"); _documentFilesDa = new DocumentFilesDA(); }